Daemon threads are interrupted when the thread main, the one that executes the method main
, ends running and the program ends.
If a thread nay is daemon, the Java process remains active and running, even when it reaches the end of the method main
and the thread main ends.
By default, the threads inherit the property of being daemon of thread that created them. Like the thread leading nay is daemon, commonly the threads created in the program are also not.
This makes it common programs that "do not end", mainly because few understand this concept or forget to create a mechanism to end threads created during the implementation of the main programme.