my statement (thread.setDaemon(true) means interrupt thread when main thread interrupted) is true?
setDaemon(true) whats mean?
my statement (thread.setDaemon(true) means interrupt thread when main thread interrupted) is true?
setDaemon(true) whats mean?
No, it's not about interrupting. It's purely about whether the thread should prevent the JVM exiting.
The JVM will terminate when there are no "non-daemon" threads left alive. If you create a bunch of threads and then let the main thread finish, and you want the program to stay running due to those threads, they should not be daemon threads. If you want the new threads to be purely background threads, and you're happy for the program to finish when the main thread finishes, then they should be daemon threads.