21.3 Asynchronous timer processing by using TimerManager
This section describes the asynchronous timer processing by using TimerManager.
The following table describes the organization of this section.
Category |
Title |
Reference location |
---|---|---|
Description |
Threads scheduling method by using TimerManager |
|
The life cycle of TimerManager |
||
The state transition of TimerManager |
||
Multiple schedules of TimerManager |
||
Implementation |
Developing applications by using TimerManager |
With the asynchronous timer processing performed by using TimerManager, you can schedule the asynchronous processing of threads in a Java EE environment by specifying an execution interval. Threads managed by a container are used in the background, and hence you can safely execute tasks.
In TimerListener, you implement the process that performs scheduling. The processing implemented in TimerListener is scheduled by executing the method of TimerManager in EJBs or servlets, which are the schedule sources. You can respond to the schedule or cancel the schedule by using Timer, which is returned from the schedule method of TimerManager.
To use TimerManager, you define the information related to TimerManager in the <resource-ref> tag of an EJB attribute or a servlet attribute. An EJB or a servlet uses TimerManager by performing a lookup with the name defined in the <res-ref-name> tag at the time of deployment.