Skip to content

Instantly share code, notes, and snippets.

@Chrisplus
Last active September 2, 2016 02:56
Show Gist options
  • Select an option

  • Save Chrisplus/d6e93373fc9e62fb6f2a9fc3f05d4670 to your computer and use it in GitHub Desktop.

Select an option

Save Chrisplus/d6e93373fc9e62fb6f2a9fc3f05d4670 to your computer and use it in GitHub Desktop.
public class PTimer extends Thread{
private int waitTime;
private int seq = 0;
private SWE swe = null;
public PTimer(int time, int s, SWE c) {
waitTime = time;
seq = s;
swe = c;
}
public void run() {
try {
sleep(waitTime);
} catch (InterruptedException e) {}
swe.generate_timeout_event(seq);
}
}
//To start a timer
PTimer timer = new PTimer(....) // set the params
timer.start()
//To stop a timer
if(timer != null){
timer.stop
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment