By registering with us, you'll be able to discuss, share and private message with other members of our community.
Sign up now!public class Waiting {
public static boolean waitFor(final Condition c, final long timeout) {
final long start = System.currentTimeMillis();
System.out.println("Waiting on a condition for max " + timeout + " ms");
while (System.currentTimeMillis() - start < timeout && !c.validate()) {
Execution.delay(20, 30);
}
System.out.println("Waited, returning " + c.validate());
return c.validate();
}
public interface Condition {
public boolean validate();
}
}
I have my own code for it
Why...I have my own code for it:
Feel free to use it.Code:public class Waiting { public static boolean waitFor(final Condition c, final long timeout) { final long start = System.currentTimeMillis(); System.out.println("Waiting on a condition for max " + timeout + " ms"); while (System.currentTimeMillis() - start < timeout && !c.validate()) { Execution.delay(20, 30); } System.out.println("Waited, returning " + c.validate()); return c.validate(); } public interface Condition { public boolean validate(); } }
I never realized it was in Execution, lmao.Why...
We use essential cookies to make this site work, and optional cookies to enhance your experience.