How does the java daemon thread run after the Java: virtual machine process exits?

with regard to daemon threads, it is stipulated that "if only daemon threads are left in the virtual machine, the virtual machine will exit."

then I think class information is always used in the daemon thread, constant pools are used, objects are allocated on the heap, etc., and the virtual machine exits. How does the java daemon thread run?

Mar.21,2021

if only the daemon thread is left in the virtual machine, the virtual machine will exit , which means that as long as one non-daemon thread does not exit, the virtual machine will not end. Only when the last non-daemon thread ends, the daemon thread ends work with the JVM.

the daemon thread ends with the end of JVM


the virtual machine exits and the daemon thread is naturally recycled.


the Java daemon thread is different from the operating system daemon (service). By definition, Java's deamon is a thread that exits and does not prevent the virtual machine from ending running.


the daemon thread ends with the end of jvm

Menu