--- old/src/hotspot/share/gc/shared/owstTaskTerminator.cpp 2018-11-30 15:40:39.581819525 +0100 +++ new/src/hotspot/share/gc/shared/owstTaskTerminator.cpp 2018-11-30 15:40:39.133806123 +0100 @@ -35,14 +35,15 @@ assert(_offered_termination < _n_threads, "Invariant"); assert(_blocker != NULL, "Invariant"); - // single worker, done + // Single worker, done. if (_n_threads == 1) { return true; } _blocker->lock_without_safepoint_check(); - // all arrived, done - if (++ _offered_termination == _n_threads) { + // All terminated, done. + _offered_termination++; + if (_offered_termination == _n_threads) { _blocker->notify_all(); _blocker->unlock(); return true; @@ -72,7 +73,7 @@ size_t tasks = tasks_in_queue_set(); if (exit_termination(tasks, terminator)) { - _offered_termination --; + _offered_termination--; _blocker->unlock(); return false; } @@ -137,7 +138,7 @@ p2i(Thread::current()), yield_count); yield_count = 0; - MonitorLockerEx locker(_blocker, Mutex::_no_safepoint_check_flag); // no safepoint check + MonitorLockerEx locker(_blocker, Mutex::_no_safepoint_check_flag); _spin_master = NULL; locker.wait(Mutex::_no_safepoint_check_flag, WorkStealingSleepMillis); if (_spin_master == NULL) { @@ -148,11 +149,11 @@ } #ifdef TRACESPINNING - _total_peeks++; + _total_peeks++; #endif size_t tasks = tasks_in_queue_set(); if (exit_termination(tasks, terminator)) { - MonitorLockerEx locker(_blocker, Mutex::_no_safepoint_check_flag); // no safepoint check + MonitorLockerEx locker(_blocker, Mutex::_no_safepoint_check_flag); if (tasks >= _offered_termination - 1) { locker.notify_all();