public void killAllProcesses ( long blockTimeMS ) { // remove already dead processes from the GUI SwingUtilities . invokeLater ( new Runnable ( ) { @ Override public void run ( ) { DefaultListModel model = ( DefaultListModel ) processList . getModel ( ) ; for ( int i = model . size ( ) - 1 ; i >= 0 ; i -- ) { ActiveProcess p = ( ActiveProcess ) model . get ( i ) ; removeProcessTab ( p , false ) ; } } } ) ; // kill processes that are already running synchronized ( processes ) { for ( int i = 0 ; i < processes . size ( ) ; i ++ ) { processes . get ( i ) . requestKill ( ) ; } } // block until everything is dead if ( blockTimeMS > 0 ) { long abortTime = System . currentTimeMillis ( ) + blockTimeMS ; while ( abortTime > System . currentTimeMillis ( ) ) { int total = 0 ; synchronized ( processes ) { for ( int i = 0 ; i < processes . size ( ) ; i ++ ) { if ( ! processes . get ( i ) . isActive ( ) ) { total ++ ; } } if ( processes . size ( ) == total ) { break ; } } } } }
Requests that all active processes be killed .