Converting main () to daemon thread is possible

According to my knowledge main()in Java, this is the default non-daemon stream, so is it possible to convert it to a daemon stream?

+4
source share
1 answer

If there are only daemon threads, then the JVM will shut down. If the main thread was a daemon thread, then the program could not work without shutting down immediately. Also, you are not allowed to set the daemon property in the stream after it starts; you cannot change the non-daemon stream to the daemon stream during its launch:

public final void setDaemon (boolean on)

. Java , .

.

+6

Source: https://habr.com/ru/post/1608582/


All Articles