@Test public void shutdownDoesNotBlockWhenTaskIsNotRunning() { CountingCallback countingCallback = new CountingCallback(true); long start = System.currentTimeMillis(); countingCallback.blockUntilSafeToShutdown(); assertThat(System.currentTimeMillis()).isLessThanOrEqualTo(start + 100L); }
public void blockUntilSafeToShutdown() { shutdownSignal = true; synchronized (this) { } }
Callback { public void blockUntilSafeToShutdown() { shutdownSignal = true; synchronized (this) { } } }
Callback { public void blockUntilSafeToShutdown() { shutdownSignal = true; synchronized (this) { } }  }
Callback { public void blockUntilSafeToShutdown() { shutdownSignal = true; synchronized (this) { } }  abstract void init(R resource); void cleanup(R resource, Throwable initException); synchronized void runWithRetry(R resource); synchronized boolean runOnceOnly(R resource); void blockUntilSafeToShutdown(); static Callback<R> noOp(); }
Callback { public void blockUntilSafeToShutdown() { shutdownSignal = true; synchronized (this) { } }  abstract void init(R resource); void cleanup(R resource, Throwable initException); synchronized void runWithRetry(R resource); synchronized boolean runOnceOnly(R resource); void blockUntilSafeToShutdown(); static Callback<R> noOp();  }