public void run() { while(true) { try { // Sleep for a while. synchronized(this) { this.wait(interval); } // Check if should terminate. // termination happens when the pool is shutting down. if(shouldTerminate) { break; } // Harvest idle threads. p.checkSpareControllers(); } catch(Throwable t) { ThreadPool.log.error("Unexpected exception", t); } } }