The way a conditional sleep functions is amongst these lines :
public boolean conditionalSleep(Condition c, long timeout) {
Timer t = new Timer(timeout);
while ((t.isRunning()) && (!c.validate())) {
sleep(20);
}
c.validate();
return c.validate();
}
Condition being following interface:
public interface Condition {
public boolean validate();
}
Excuse the shit indentation :p