Reputation: 141
I find DestroyJavaVM thread using 99% of the cpu (about one cpu core) when the application starts. I can not find any document for this thread. One answer in StackOverflow said that this thread does nothing but joins other no daemon threads. This confused me why it uses so much cpu when the application starts. I also find one post said that the DestroyJavaVM thread is parent thread of other thread, the top command accumulate all children use rate to parent. But when I use pstree comman to show java thread tree, that is not true.
Upvotes: 1
Views: 939
Reputation: 98330
DestroyJavaVM
is not a separate thread. It's basically a Java thread that initiates VM shutdown, i.e. either the last non-daemon application thread, or a thread that calls System.exit()
.
When JVM is about to terminate, it renames the current thread to DestroyJavaVM
and initiates the shutdown sequence using this thread.
In the case of a simple application, when all the business logic is called from the main
method, it will be the Main thread that is renamed to DestroyJavaVM
when the main
method returns. What you observe is probably just the Main thread that consumes CPU for its primary job.
Upvotes: 4