public void setPaused ( boolean paused ) { // Make use of a lock when modifying the paused variable to avoid any race conditions pauseLock . lock ( ) ; this . paused = paused ; // Wake up all threads that are currently paused if ( ! this . paused ) pausedCondition . signalAll ( ) ; pauseLock . unlock ( ) ; }
Sets the paused state of the thread and if the thread needs to be resumed and was paused and sleeping it gets signaled .