public void waitAllTasks ( ) { synchronized ( this . tasks ) { while ( this . hasTaskPending ( ) ) { try { this . tasks . wait ( ) ; } catch ( InterruptedException e ) { e . printStackTrace ( ) ; } } synchronized ( this . tasksReachesZero ) { if ( this . runningTasks > 0 ) { try { this . tasksReachesZero . wait ( ) ; } catch ( InterruptedException e ) { e . printStackTrace ( ) ; } } } } }
Wait that every pending task are processed . This method will return once it has no pending task or once it has been closed