JavaXT
|
|||||||||||||||||||||||||||||
Timer ClassUsed to schedule tasks for future execution in a background thread. Tasks may be scheduled for one-time execution, or for repeated execution at regular intervals. Unlike the java.util.Timer class, this implementation does not silently cancel tasks if a task encounters an exception.
Constructors Timer( )
Public Methodsschedule( Runnable task, long delay ) returns void Schedules the specified task for execution after the specified delay.
schedule( Runnable task, java.util.Date time ) returns void Schedules the specified task for execution at the specified time. If the time is in the past, the task is scheduled for immediate execution.
scheduleAtFixedRate( Runnable task, java.util.Date firstTime, long period ) returns void Schedules the specified task for repeated fixed-rate execution, beginning at the specified time. Subsequent executions take place at regular intervals, separated by the specified period.
scheduleAtFixedRate( Runnable task, long delay, long period ) returns void Schedules the specified task for repeated fixed-rate execution, beginning at the specified time. Subsequent executions take place at regular intervals, separated by the specified period.
Static MethodssetInterval( Callback callback, long interval ) returns Timer Used to repeatedly call a given function/callback, with a fixed time delay between each call. Example:
setInterval(()->{ System.out.println(new java.util.Date()); }, 1000);
setTimeout( Callback callback, long delay ) returns Timer Used to call a given function/callback after a delay. Example:
long startTime = System.currentTimeMillis(); setTimeout(()->{ System.out.println(System.currentTimeMillis()-startTime); }, 1000);
Public Classes |