8202564: java/lang/management/ThreadMXBean/ThreadCounts.java fails
authormdoerr
Tue, 08 May 2018 15:40:03 +0200
changeset 50065 ae0ebd3cf949
parent 50064 e4a7bacf99b1
child 50066 bd3e4517dfa3
8202564: java/lang/management/ThreadMXBean/ThreadCounts.java fails Summary: _exiting_daemon_threads_count needs to be decremented at the right place Reviewed-by: kvn, dcubed
src/hotspot/share/services/threadService.cpp
--- a/src/hotspot/share/services/threadService.cpp	Wed May 09 09:50:25 2018 +0800
+++ b/src/hotspot/share/services/threadService.cpp	Tue May 08 15:40:03 2018 +0200
@@ -122,6 +122,9 @@
 
 void ThreadService::remove_thread(JavaThread* thread, bool daemon) {
   Atomic::dec(&_exiting_threads_count);
+  if (daemon) {
+    Atomic::dec(&_exiting_daemon_threads_count);
+  }
 
   if (thread->is_hidden_from_external_view() ||
       thread->is_jvmti_agent_thread()) {
@@ -129,10 +132,8 @@
   }
 
   _live_threads_count->set_value(_live_threads_count->get_value() - 1);
-
   if (daemon) {
     _daemon_threads_count->set_value(_daemon_threads_count->get_value() - 1);
-    Atomic::dec(&_exiting_daemon_threads_count);
   }
 }