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.

Revisions

  1. Chrisplus created this gist Sep 2, 2016.
    28 changes: 28 additions & 0 deletions Timer Example
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,28 @@
    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
    }