blob: e3380d104c8847e456a2e9ba33b0e7bce9d70d26 [file] [log] [blame]
/*
* $Id$
* $Date$
*/
package org.testng.internal.thread;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
/**
* ICountDown adapter using the features in JDK 1.5, e.g.
* <CODE>CountDownLatch</CODE>.
*
* @author <a href="mailto:the_mindstorm@evolva.ro>the_mindstorm</a>
* @version $Revision$
*/
public class CountDownAdapter implements ICountDown {
protected CountDownLatch m_doneLatch;
public CountDownAdapter(int count) {
m_doneLatch = new CountDownLatch(count);
}
public void await() throws InterruptedException {
m_doneLatch.await();
}
public boolean await(long timeout) throws InterruptedException {
return m_doneLatch.await(timeout, TimeUnit.MILLISECONDS);
}
public void countDown() {
m_doneLatch.countDown();
}
}