private void adjustPoolSize ( ) { if ( lastCheck + 1000 < System . currentTimeMillis ( ) ) { int n = Runtime . getRuntime ( ) . availableProcessors ( ) ; if ( numProcessors != n ) { executor . setMaximumPoolSize ( n ) ; numProcessors = n ; } lastCheck = System . currentTimeMillis ( ) ; } }
Adjusts the pool size at most once every second .