public InternalStatus get() { if (done != null) { return done; } else if (owner == Thread.currentThread()) { return to.compareTo(from()) > 0 ? to : from(); } synchronized (this) { boolean interrupted = false; try { while (done == null) { try { wait(); } catch (InterruptedException e) { interrupted = true; } } } finally { if (interrupted) { Thread.currentThread().interrupt(); } } return done; } }
public synchronized void failed() { done = to.compareTo(from()) > 0 ? from() : to; notifyAll(); }