--- old/src/share/vm/gc/shared/workgroup.cpp 2015-05-20 11:05:23.898138992 +0200 +++ new/src/share/vm/gc/shared/workgroup.cpp 2015-05-20 11:05:23.758134262 +0200 @@ -434,7 +434,7 @@ // SubTasksDone functions. SubTasksDone::SubTasksDone(uint n) : - _n_tasks(n), _n_threads(1), _tasks(NULL) { + _n_tasks(n), _tasks(NULL) { _tasks = NEW_C_HEAP_ARRAY(uint, n, mtInternal); guarantee(_tasks != NULL, "alloc failure"); clear(); @@ -444,12 +444,6 @@ return _tasks != NULL; } -void SubTasksDone::set_n_threads(uint t) { - assert(_claimed == 0 || _threads_completed == _n_threads, - "should not be called while tasks are being processed!"); - _n_threads = (t == 0 ? 1 : t); -} - void SubTasksDone::clear() { for (uint i = 0; i < _n_tasks; i++) { _tasks[i] = 0; @@ -477,7 +471,7 @@ return res; } -void SubTasksDone::all_tasks_completed() { +void SubTasksDone::all_tasks_completed(uint n_threads) { jint observed = _threads_completed; jint old; do { @@ -485,7 +479,10 @@ observed = Atomic::cmpxchg(old+1, &_threads_completed, old); } while (observed != old); // If this was the last thread checking in, clear the tasks. - if (observed+1 == (jint)_n_threads) clear(); + uint adjusted_thread_count = (n_threads == 0 ? 1 : n_threads); + if (observed + 1 == (jint)adjusted_thread_count) { + clear(); + } }