Jump to content

Dynamic Sleeping


Recommended Posts

Posted (edited)

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

Edited by Articron
  • Like 1
Posted

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 tongue.png

nice to see you back

  • Like 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...