![]() The actual execution time of the previous execution. In fixed-delay execution, each execution is scheduled relative to Subsequent executions take placeĪt approximately regular intervals separated by the specified period. Long period) Schedules the specified task for repeated fixed-delay execution,īeginning after the specified delay. Throws: IllegalArgumentException - if time.getTime() is negative.Ĭancelled, timer was cancelled, or timer thread terminated. time - time at which task is to be executed. The time is in the past, the task is scheduled for immediate execution. IllegalStateException - if task was already scheduled orĭate time) Schedules the specified task for execution at the specified time. ![]() Throws: IllegalArgumentException - if delay is negative, orĭelay + System.currentTimeMillis() is negative. delay - delay in milliseconds before task is to be executed. Long delay) Schedules the specified task for execution after the specified delay. Parameters: isDaemon - true if the associated thread should run as a daemon. A deamon thread is called for if the timer willīe used to schedule repeating "maintenance activities", which mustīe performed as long as the application is running, but should not Public Timer(boolean isDaemon) Creates a new timer whose associated thread may be specified to Timer as such a finalizer would be susceptible to a subclass's It is used in preference to a finalizer on Private Object threadReaper This object causes the timer's task execution thread to exit Private TimerThread thread The timer thread. The timer produces tasks, via its various schedule calls,Īnd the timer thread consumes, executing timer tasks as appropriate,Īnd removing them from the queue when they're obsolete. This data structure is shared with the timer Private TaskQueue queue The timer task queue. ObjectĬlone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait Schedules the specified task for repeated fixed-rate execution, Schedules the specified task for execution after the specified delay. Schedules the specified task for repeated fixed-delay execution, Schedules the specified task for execution at the specified time. Time with the specified period, in milliseconds. Schedule the specifed timer task for execution at the specified Terminates this timer, discarding any currently scheduled tasks. Gracefully when there are no live references to the Timer object and noĬreates a new timer whose associated thread may be specified to This object causes the timer's task execution thread to exit Since: 1.3 Author: Josh Bloch See Also: TimerTask, It uses a binary heap to represent its task queue, so the cost to scheduleĪ task is O(log n), where n is the number of concurrently scheduled tasks. Scheduled tasks (thousands should present no problem). Implementation note: This class scales to large numbers of concurrently Tasks using the Object.wait(long) method. This class does not offer real-time guarantees: it schedules Timer object without the need for external synchronization. This class is thread-safe: multiple threads can share a single IllegalStateException, as if the timer's cancel If the timer's task execution thread terminates unexpectedly, forĮxample, because its stop method is invoked, any furtherĪttempt to schedule a task on the timer will result in an Should invoke the the timer's cancel method. Wants to terminate a timer's task execution thread rapidly, the caller ![]() So it is capable of keeping an application from terminating. Byĭefault, the task execution thread does not run as a daemon thread, However, this can take arbitrarily long to occur. Turn, delay the execution of subsequent tasks, which may "bunch up" andĮxecute in rapid succession when (and if) the offending task finallyĪfter the last live reference to a Timer object goes awayĪnd all outstanding tasks have completed execution, the timer's taskĮxecution thread terminates gracefully (and becomes subject to garbageĬollection). To complete, it "hogs" the timer's task execution thread. Thread that is used to execute all of the timer's tasks, sequentially. Tasks may be scheduled for one-time execution, or forĬorresponding to each Timer object is a single background ![]() SUMMARY: NESTED | FIELD | CONSTR | METHODĬlass Timer Ī facility for threads to schedule tasks for future execution in aīackground thread.
0 Comments
Leave a Reply. |