private void runTasks ( ) { ClassLoader systemClassLoader = ClassLoader . getSystemClassLoader ( ) ; ThreadPoolBase pool = _pool ; Thread thread = this ; Outbox outbox = outbox ( ) ; boolean isWake = false ; setName ( _name ) ; while ( ! _isClose ) { RunnableItem taskItem = pool . poll ( isWake ) ; isWake = false ; if ( taskItem != null ) { try { _launcher . onChildIdleEnd ( ) ; outbox . open ( ) ; do { // if the task is available, run it in the proper context thread . setContextClassLoader ( taskItem . getClassLoader ( ) ) ; taskItem . getTask ( ) . run ( ) ; outbox . flushAndExecuteAll ( ) ; } while ( ( taskItem = pool . poll ( false ) ) != null ) ; } catch ( Throwable e ) { log . log ( Level . WARNING , e . toString ( ) , e ) ; } finally { try { outbox . close ( ) ; } catch ( Throwable e ) { e . printStackTrace ( ) ; } _launcher . onChildIdleBegin ( ) ; thread . setContextClassLoader ( systemClassLoader ) ; if ( ! thread . getName ( ) . equals ( _name ) ) { setName ( _name ) ; } } } else if ( _launcher . isIdleExpire ( ) ) { return ; } else if ( park ( ) ) { //thread.onWakeThread(); isWake = true ; } else { return ; } } }
Main thread loop .