List of usage examples for java.util.concurrent TimeoutException TimeoutException
public TimeoutException()
From source file:org.apache.zookeeper.server.quorum.QuorumPeerMainTest.java
private QuorumPeer waitForQuorumPeer(MainThread mainThread, int timeout) throws TimeoutException { long start = Time.currentElapsedTime(); while (true) { QuorumPeer quorumPeer = mainThread.isAlive() ? mainThread.getQuorumPeer() : null; if (quorumPeer != null) { return quorumPeer; }/*from ww w . j av a 2 s . c o m*/ if (Time.currentElapsedTime() > start + timeout) { LOG.error("Timed out while waiting for QuorumPeer"); throw new TimeoutException(); } try { Thread.sleep(250); } catch (InterruptedException e) { // ignore } } }