< prev index next >

src/share/vm/gc/shared/workgroup.cpp

Print this page
rev 11459 : create_thread_failed: fix errors from thread creation failures

@@ -269,12 +269,15 @@
 void WorkGang::run_task(AbstractGangTask* task, uint num_workers) {
   guarantee(num_workers <= total_workers(),
             "Trying to execute task %s with %u workers which is more than the amount of total workers %u.",
             task->name(), num_workers, total_workers());
   guarantee(num_workers > 0, "Trying to execute task %s with zero workers", task->name());
-  add_workers(num_workers, false);
-  _dispatcher->coordinator_execute_on_workers(task, num_workers);
+  // num_workers may have been calculated based on different criteria
+  // than _active_workers so use num_workers limited by the number of
+  // created workers.
+  uint active_workers = MIN2(_created_workers, num_workers);
+  _dispatcher->coordinator_execute_on_workers(task, active_workers);
 }
 
 AbstractGangWorker::AbstractGangWorker(AbstractWorkGang* gang, uint id) {
   _gang = gang;
   set_id(id);
< prev index next >