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 , .
.