One misconception I would like to clarify:
- Assume that if daemon thread (say B) is created within user thread (sayA); then ending of this user thread/parent thread (A) will not endthe daemon thread/child thread (B) it has created; provided user thread is the onlyone currently running.
- So there is no parent-child relationship on thread ending. All daemon threads (irrespective of where it is created) will end once there is no single live user thread and that causes JVM to terminate.
- Even this is true for both (parent/child) are daemon threads.
- If a child thread created from a daemon thread then that is also a daemon thread. This won't need any explicit daemon thread flag setting.Similarly if a child thread created from a user thread then that is also a user thread, if you want to change it, then explicit daemon flag setting is needed before start of that child thread.