package org.wamblee.socketproxy; /** * Copyright (c) 2005 UPS_SCS NL * */ public class Barrier { private int _countLeft; public Barrier( int aCount ) { _countLeft = aCount; } public synchronized void block( ) { _countLeft--; if ( _countLeft < 0 ) { throw new IllegalStateException( "Barrier count became negative, programming error" ); } notifyAll( ); while ( _countLeft > 0 ) { waitUninterruptable( ); } } private void waitUninterruptable( ) { try { wait( ); } catch ( InterruptedException e ) { // ignore. } } }