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
--- 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);
}
}