I have this idea, I have not tested it, but I think it will work:
You can expand the flow and redefine sleep to switch state. Something like that:
@Override public static void sleep(long millis, int nanos) throws InterruptedException { SLEEPMARKER = true; super.sleep(millis, nanos); SLEEPMARKER = false; } @Override public static void sleep(long millis) throws InterruptedException { SLEEPMARKER = true; super.sleep(millis); SLEEPMARKER = false; }
To do this, you only need a marker and getter.
public static boolean SLEEPMARKER = false; public static boolean isSleeping(){ return SLEEPMARKER; }
source share