question: @ Override public < T > Future < T > submit ( Callable < T > task ) { synchronized ( this ) { active . incrementAndGet ( ) ; long timeout = 0 ; while ( queue . remainingCapacity ( ) == 0 ) { try { if ( timeout <= giveupTime ) { Thread . sleep ( DEFAULT_SLEEP ) ; timeout += DEFAULT_SLEEP ; } else { throw new RuntimeException ( "Timed out because TPE is too busy..." ) ; } } catch ( InterruptedException e ) { throw new RuntimeException ( e ) ; } } return super . submit ( task ) ; } }
target:  This is a thread safe way to avoid rejection exception... this is implemented because we might want to hold the incoming requests till there is a free thread.