public void waitUntilWorkDone ( ) { while ( objectListSize ( ) > 0 || getRunningThreadNumber ( ) > 0 ) { if ( stopped ) { log . fatal ( "El pool se ha parado de forma anormal. List Size:" + objectListSize ( ) + " running threads:" + getRunningThreadNumber ( ) + "/" + getThreadPoolSize ( ) ) ; return ; } if ( log . isDebugEnabled ( ) ) { log . debug ( "List Size:" + objectListSize ( ) + " running threads:" + getRunningThreadNumber ( ) + "/" + getThreadPoolSize ( ) ) ; } try { log . info ( "STILL WAITING List Size:" + objectListSize ( ) + " running threads:" + getRunningThreadNumber ( ) + "/" + getThreadPoolSize ( ) ) ; Thread . sleep ( 1000 ) ; } catch ( InterruptedException e ) { } } log . info ( " Calling threadWorkDone." ) ; for ( InnerConsumerThread thread : threadList ) { try { // update the work done flag and notify thre thread thread . threadWorkDone ( ) ; synchronized ( thread ) { thread . notify ( ) ; } } catch ( Throwable e ) { log . error ( "Error in threadWorkDone for thread:" + thread . getName ( ) , e ) ; } } synchronized ( objectList ) { objectList . notifyAll ( ) ; } if ( log . isInfoEnabled ( ) ) { log . info ( "Work, done. List Size:" + objectListSize ( ) + " running threads:" + getRunningThreadNumber ( ) + "/" + getThreadPoolSize ( ) ) ; } log . info ( "FINISH: Work, done. List Size:" + objectListSize ( ) + " running threads:" + getRunningThreadNumber ( ) + "/" + getThreadPoolSize ( ) ) ; }
Wait the current Thread until the work is done