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.
For non-daemon thread, the program, say - the thread runs main(), will not terminate until all threads complete. But for daemon, since it is supposed to run in the background of one program, the program can terminate once the main() finishes its job, even those daemon threads are still active. My question is, Assume a daemon thread has an infinite loop, will it continue running after the main() finished? So it *seems* that the program is finished, but indeed, it's not really done yet. One needs to kill the process manually sometime later when he noticed this, is this a potential hole? What are daemon threads use for then? :roll: Thanks very much -Yan
Hi Yan Bai, There's nothing special about the 'main program' thread, it's just another user thread. That being said, the Java runtime terminates only if there are no more user threads running, the main() method among them. Hope this helps, Paul Villangca