--- old/src/hotspot/share/trace/tracingExport.cpp 2018-04-03 17:00:16.000000000 -0400 +++ new/src/hotspot/share/trace/tracingExport.cpp 2018-04-03 17:00:15.000000000 -0400 @@ -26,13 +26,15 @@ #include "runtime/orderAccess.inline.hpp" #include "trace/tracingExport.hpp" -// Allow lock-free access to _sampler_thread. +// Allow lock-free reads of _sampler_thread. Thread* volatile TracingExport::_sampler_thread = NULL; -Thread* TracingExport::get_sampler_thread() { +Thread* TracingExport::sampler_thread_acquire() { return (Thread*)OrderAccess::load_acquire(&_sampler_thread); } -void TracingExport::set_sampler_thread(Thread* thread) { - OrderAccess::release_store_fence(&_sampler_thread, thread); +void TracingExport::set_sampler_thread_with_lock(Thread* thread) { + // Grab Threads_lock to avoid conflicts with Thread-SMR scans. + MutexLocker ml(Threads_lock); + _sampler_thread = thread; }