If main
thread ends if there are still non daemon thread present than program will keep running.
If there are only daemon thread present than as soon as main thread completes program ends.
What is daemon thread?
before you start a thread you can set it as daemon thread by
setDaemon(boolean value)
if thread is daemon it only runs as long as other user threads have not completed.
b. A program will terminate only when all user threads stop running
is true statement.
daemon thread are generally present to support other thread they run in background for e.g. say garbage collector thread if program stops executing main ends now there is no point in running gc thread as program stops and OS will reclaim memmory. however program does not finish executing as long as there is non daemon thread present.
[ September 09, 2005: Message edited by: Santana Iyer ]