Timer class.
@author Denis Neuling (denisneuling@gmail.com)Timer
is a ReadOnlyTimer implementation with nanosecond resolution.
Timer
interface defines the common interface implemented by all classes whose instances serve as pluggable timers.
@author Mike Clark
@author Clarkware Consulting, Inc.
Timer class.
@author Denis Neuling (denisneuling@gmail.com)To schedule a timer, simply create a subclass of it (overriding {@link #run}) and call {@link #schedule} or {@link #scheduleRepeating}.
NOTE: If you are using a timer to schedule a UI animation, use {@link com.google.gwt.animation.client.AnimationScheduler} instead. Thebrowser can optimize your animation for maximum performance.
Dieser Timer hilft dabei Zeitabschnitte zu messen.
Die Genaugkeit hängt von der Rechenleistung des PCs ab, ist aber auf keinen Fall für exakte Berechnungen geeignet.
Ein Timer hat die Zustände laufend und nicht laufend. Um zwischen diesen Zuständen zu wechseln, kann er gestartet oder gestoppt werden. Nach dem erzeugen läuft er noch nicht. Sobald die eingestellte Zeit abgelaufen ist, wird der Timer gestoppt.
@author niklasTimer
is the base class for a high resolution timer. It is created from getTimer("display system")
@author Mark Powell
@version $Id: Timer.java,v 1.18 2007/03/09 10:19:34 rherlitz Exp $
Timer
defines the basic Timer behavior..
@author Vlad Mihalcea
@version %I%, %E%
@since 1.0
Corresponding to each Timer object is a single background thread that is used to execute all of the timer's tasks, sequentially. Timer tasks should complete quickly. If a timer task takes excessive time to complete, it "hogs" the timer's task execution thread. This can, in turn, delay the execution of subsequent tasks, which may "bunch up" and execute in rapid succession when (and if) the offending task finally completes.
After the last live reference to a Timer object goes away and all outstanding tasks have completed execution, the timer's task execution thread terminates gracefully (and becomes subject to garbage collection). However, this can take arbitrarily long to occur. By default, the task execution thread does not run as a daemon thread, so it is capable of keeping an application from terminating. If a caller wants to terminate a timer's task execution thread rapidly, the caller should invoke the timer's cancel method.
If the timer's task execution thread terminates unexpectedly, for example, because its stop method is invoked, any further attempt to schedule a task on the timer will result in an IllegalStateException, as if the timer's cancel method had been invoked.
This class is thread-safe: multiple threads can share a single Timer object without the need for external synchronization.
This class does not offer real-time guarantees: it schedules tasks using the Object.wait(long) method.
Implementation note: This class scales to large numbers of concurrently scheduled tasks (thousands should present no problem). Internally, it uses a binary heap to represent its task queue, so the cost to schedule a task is O(log n), where n is the number of concurrently scheduled tasks.
Implementation note: All constructors start a timer thread. @author Josh Bloch @version 1.19, 01/27/06 @see TimerTask @see Object#wait(long) @since 1.3
Setting the sleep interval to value less than 15 ms is questionable since some operating systems do not provide such precision. Moreover such values may impact test performance.
In case of no stop conditions are specified, timer logic corresponds to regular {@link Thread#sleep(long)} execution.
Setting the sleep interval to the value less than 15 ms is questionable since some operating systems do not provide such precision. Moreover such values may impact test performance.
In case of no stop conditions are specified (not recommended), the timer logic corresponds to the regular {@link Thread#sleep(long)} execution.
Class used to keep track how much time is spent for a specific operation. Timers are primarily used to display info about performance. A timer is started at the beginning of a function and is stopped at the end of that function (special care needed when there are multiple return commands in a function because the status of unstopped timers is undefined). A timer also stores how many times the timer has been started so average time spent in a function can be computed.
When a timer is used in a recursive function it will typically be started multiple times. Timer class will only measure the time spent in the first call. This is done by counting how many times a timer is started and time spent is computed only when the number of stop() calls evens out the start() calls. It is the programmer's responsibility to make sure each start() is stopped by a stop() call.
Each timer may be associated with a timeout limit. This means that time spent between start() and stop() calls should be less than the timeout specified. Timeouts will only be checked when check() function is called. If check() function is not called setting timeouts has no effect. It is up to the programmer to decide when and how many times a timer will be checked.
There may be a dependency between timers. For example, classification, realization and entailment operations all use consistency checks. If something goes wrong inside a consistency check and that operation does not finish in a reasonable time, the timeout on the parent timer may expire. To handle such cases, a timer may be associated with a parent timer so every time a timer is checked for a timeout, its parent timer will also be checked. Normally, we would like to associate many parents with a timer but for efficiency reasons (looping over an array each time is expensive) each timer is allowed to have only one parent.
{@link Timers Timers} class stores a set of timers and provides functions to start, stop andcheck timers.
@see Timers @author Evren Sirin{@link Timer} is a special component that is invisible.
Notice that the timer won't fire any event until it is attached to a page. @author tomyeh
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|