# HG changeset patch # User sangheki # Date 1428599805 25200 # Node ID 9b582718fbea74e61c9e09923211c002c047ea78 # Parent 421863f11ad7291c3a45c807925cbfa4f9297716 8076325: java hangs with -XX:ParallelGCThreads=0 -XX:+ExplicitGCInvokesConcurrent options Summary: Added a guard of gc workers > 0 to execute logic. Reviewed-by: stefank, mgerdin diff -r 421863f11ad7 -r 9b582718fbea src/share/vm/gc_implementation/g1/g1RootProcessor.cpp --- a/src/share/vm/gc_implementation/g1/g1RootProcessor.cpp Fri Apr 10 09:55:46 2015 -0700 +++ b/src/share/vm/gc_implementation/g1/g1RootProcessor.cpp Thu Apr 09 10:16:45 2015 -0700 @@ -93,11 +93,13 @@ uint n_workers = _g1h->n_par_threads(); assert(ClassUnloadingWithConcurrentMark, "Currently only needed when doing G1 Class Unloading"); - uint new_value = (uint)Atomic::add(1, &_n_workers_discovered_strong_classes); - if (new_value == n_workers) { - // This thread is last. Notify the others. - MonitorLockerEx ml(&_lock, Mutex::_no_safepoint_check_flag); - _lock.notify_all(); + if (n_workers > 0) { + uint new_value = (uint)Atomic::add(1, &_n_workers_discovered_strong_classes); + if (new_value == n_workers) { + // This thread is last. Notify the others. + MonitorLockerEx ml(&_lock, Mutex::_no_safepoint_check_flag); + _lock.notify_all(); + } } } @@ -105,7 +107,7 @@ uint n_workers = _g1h->n_par_threads(); assert(ClassUnloadingWithConcurrentMark, "Currently only needed when doing G1 Class Unloading"); - if ((uint)_n_workers_discovered_strong_classes != n_workers) { + if (n_workers > 0 && (uint)_n_workers_discovered_strong_classes != n_workers) { MonitorLockerEx ml(&_lock, Mutex::_no_safepoint_check_flag); while ((uint)_n_workers_discovered_strong_classes != n_workers) { _lock.wait(Mutex::_no_safepoint_check_flag, 0, false);