Originally posted by Jose Botella:
The program results show perfectly the behaviour of threads.
Forget for a moment the fact that one is daemon and recognize that sometimes the thread begins before the printing sentence, and in other ocasions after it. You have even seen a case where the progam ended before the beginning of the execution of the thread.
Now, in the last two results the task of the thread was so minimal that it ended before the termination of the program. Thus there is no contradiction with your statement.
For watching how a daemon thread doesn't prevent the program termination place the thread whithin an infinite loop. Compare the behavior of the program. Besides try not setting the thread to daemon. Be ready to push crtl-c ;-)
Jose, Thankx for the response.
The outputs are consistent when the child-thread is not set to
daemon thread. Here again the task for thread is minimal but
outputs are :
1. User/Main thread
2. Child thread's run method
Abnormality output is when the child-thread becomes Daemon?
I am curious to learn more about this setting.
Could you please share your comments/thoughts..