1. Creating a Timer object is to start a new thread, but this newly started thread is not a daemon thread, it runs in the background all the time. The newly started Timer thread can be set as a daemon thread by the following. private static Timer timer=new Timer(true); 2. Advance: When the planned time is earlier than the current time, the task will be run immediately.
|