use of com.google.common.util.concurrent.MoreExecutors.newDirectExecutorService in project guava by google.
the class MoreExecutorsTest method testDirectExecutorService_awaitTermination_missedSignal.
/**
* Test for a bug where threads weren't getting signaled when shutdown was called, only when
* tasks completed.
*/
public void testDirectExecutorService_awaitTermination_missedSignal() {
final ExecutorService service = MoreExecutors.newDirectExecutorService();
Thread waiter = new Thread() {
@Override
public void run() {
try {
service.awaitTermination(1, TimeUnit.DAYS);
} catch (InterruptedException e) {
return;
}
}
};
waiter.start();
awaitTimedWaiting(waiter);
service.shutdown();
Uninterruptibles.joinUninterruptibly(waiter, 10, TimeUnit.SECONDS);
if (waiter.isAlive()) {
waiter.interrupt();
fail("awaitTermination failed to trigger after shutdown()");
}
}
Aggregations