Runnable showResultsAction = new Runnable() {
public void run() {
showResults();
results.clear();
} };
barrier = new CyclicBarrier( args.length, showResultsAction );
for ( final String site : args )
new Thread() {
public void run() {
while( true ) {
long time = timeConnect( site );
results.add( new Result( time, site ) );
try {
barrier.await();
} catch ( BrokenBarrierException e ) { return;
} catch ( InterruptedException e ) { return; }
}
}
}.start();