Recent projects have appeared in the timing of the task of the things, research, think very good, and later use to get, summed up the next.
Only two types of java.util.Timer and quarts are introduced here.
Java.util.Timer
Java comes with a tool class that the thread uses to schedule tasks to perform later in the background thread. You can schedule a task to execute once, or repeat it periodically, and use it with Java.util.TimerTask for ease of use. The sample code is as follows:
ImportJava.util.Timer;ImportJava.util.TimerTask; Public classtes { Public Static voidMain (string[] args) {Timer timer=NewTimer (); Timer.schedule (NewMytimertask (), 1000, 2000); }}classMytimertaskextendstimertask{@Override Public voidrun () {System.out.println ("================"); }}
The code is simple and easy to use, but the java.util.TimerTask can only be executed at regular intervals and cannot be repeated at a fixed point in time.
Quarts
Quarts can be configured to perform tasks at a fixed point in time, which is slightly more complex, but powerful.
Today's time is not enough, head a bit uncomfortable, tomorrow research research and write again.
Timer articles---java.util.TimerTask and quarts