Java Timer

From NovaOrdis Knowledge Base
Revision as of 02:46, 31 July 2016 by Ovidiu (talk | contribs)
Jump to navigation Jump to search

External

Internal

Overview

The Java java.util.Timer allows a task to be scheduled for execution at a specified time, or with a fixed delay, or at a fixed rate.

class TimerThread extends Thread {
    ...
    private void mainLoop() {
        while (true) {
            try {
                ...
                if (taskFired)  // Task fired; run it, holding no locks
                    task.run();
            } catch(InterruptedException e) {
            }
        }
    }
   ...
}