private Worker getWorker ( ) throws InterruptedException { while ( ! courtesyMonitor . allowTasksToRun ( ) ) { courtesyMonitor . waitFor ( ) ; } while ( numWorkers > maxWorkers ) { workerQueue . take ( ) ; numWorkers -- ; } return workerQueue . take ( ) ; }
Gets the next worker available to process a task .