--- old/src/hotspot/share/runtime/thread.cpp Tue Nov 21 14:38:36 2017 +++ new/src/hotspot/share/runtime/thread.cpp Tue Nov 21 14:38:35 2017 @@ -3429,10 +3429,15 @@ // ======= Threads ======== // The Threads class links together all active threads, and provides -// operations over all threads. It is protected by its own Mutex -// lock, which is also used in other contexts to protect thread -// operations from having the thread being operated on from exiting -// and going away unexpectedly (e.g., safepoint synchronization) +// operations over all threads. It is protected by the Threads_lock, +// which is also used in other global contexts like safepointing. +// ThreadsListHandles are used to safely perform operations on one +// or more threads without the risk of the thread exiting during the +// operation. +// +// Note: The Threads_lock is currently more widely used than we +// would like. We are actively migrating Threads_lock uses to other +// mechanisms in order to reduce Threads_lock contention. JavaThread* Threads::_thread_list = NULL; int Threads::_number_of_threads = 0; @@ -4891,8 +4896,8 @@ // Retry the whole scenario. } - // If someone set a handshake on us just as we entered exit path, we simple cancel it. if (ThreadLocalHandshakes) { + // The thread is about to be deleted so cancel any handshake. thread->cancel_handshake(); }