This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I want to write a code to make a daemon thread. That thread should be running in the background every time as and when the system started(Ex-jvm). And also this should execute particular method in the midnight.
In Java, any thread can be a Daemon thread. Daemon threads are like a service providers for other threads or objects running in the same process as the daemon thread. Daemon threads are used for background supporting tasks and are only needed while normal threads are executing. If normal threads are not running and remaining threads are daemon threads then the interpreter exits.
setDaemon(true/false) ・/b> This method is used to specify that a thread is daemon thread.
public boolean isDaemon() ・ This method is used to determine the thread is daemon thread or not.
The following program demonstrates the Daemon Thread: