Machine-translated by Google. Questions are authored in English.
Top

Discussion

When the JVM exits - which of the following is true?

  • A.The JVM waits for every thread.
  • B.The JVM exits once every daemon thread has finished.
  • C.The JVM exits once the only threads still running are daemon threads.
  • D.The JVM exits once the main thread returns.

Answer: C

Execution continues until all non-daemon threads have died, or Runtime.exit is called; the JVM exits when the only threads running are daemons. So main returning does not end the program if a non-daemon thread is still alive, and a daemon can be killed mid-work at shutdown.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.