--- old/src/hotspot/share/runtime/serviceThread.cpp 2019-08-28 15:04:01.314957339 -0400 +++ new/src/hotspot/share/runtime/serviceThread.cpp 2019-08-28 15:04:01.130957346 -0400 @@ -190,25 +190,21 @@ // Deflate any global idle monitors. ObjectSynchronizer::deflate_global_idle_monitors_using_JT(); - // deflate_per_thread_idle_monitors_using_JT() is called by - // each JavaThread from ObjectSynchronizer::omAlloc() as needed. int count = 0; for (JavaThreadIteratorWithHandle jtiwh; JavaThread *jt = jtiwh.next(); ) { - if (jt->om_in_use_count > 0) { - // This JavaThread is using monitors so request deflation. - jt->om_request_deflation = true; + if (jt->om_in_use_count > 0 && !jt->is_exiting()) { + // This JavaThread is using ObjectMonitors so deflate any that + // are idle unless this JavaThread is exiting; do not race with + // ObjectSynchronizer::om_flush(). + ObjectSynchronizer::deflate_per_thread_idle_monitors_using_JT(jt); count++; } } if (count > 0) { - log_debug(monitorinflation)("requesting async deflation of idle monitors for %d thread(s).", count); + log_debug(monitorinflation)("did async deflation of idle monitors for %d thread(s).", count); } // The ServiceThread's async deflation request has been processed. ObjectSynchronizer::set_is_async_deflation_requested(false); - - // The global in-use list was handled above, but the request won't - // be complete until the JavaThreads have handled their in-use - // lists. This is the nature of an async deflation request. } } }