Hi all, will daemon thread stop working when the enclosing it thread will finish? Or daemon thread will stop when the \"main\" thread will finish?
I tested this example
will daemon thread stop working when the enclosing it thread will finish?
There's no such concept as an "enclosing thread" in Java. There are thread groups but they're rarely used.
Daemon threads are simply threads which don't stop the JVM from terminating. When there aren't any non-daemon threads left, the JVM will terminate. If there are still some non-daemon threads executing, the JVM will keep going, including any daemon threads - whether or not the threads that started those daemon threads have finished.