### Question:
InlineExecutorService extends AbstractExecutorService { @Override public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException { long nanos = unit.toNanos(timeout); while (nanos > 0) { myLock.lock(); try { if (isTerminated()) { return true; } nanos = myCondition.awaitNanos(nanos); } finally { myLock.unlock(); } } return isTerminated(); } InlineExecutorService(); @Override boolean awaitTermination(long timeout, TimeUnit unit); @Override final void execute(Runnable command); @Override boolean isShutdown(); @Override boolean isTerminated(); @Override void shutdown(); @Override List<Runnable> shutdownNow();  }### Answer:
@Test public void testAwaitTermination() throws InterruptedException { ExecutorService pool = Executors.newFixedThreadPool(2); final CountDownLatch latch = new CountDownLatch(2); final AtomicBoolean flag1 = new AtomicBoolean(); final AtomicBoolean flag2 = new AtomicBoolean(); final ExecutorService service = new InlineExecutorService(); pool.execute(new TestRunnable(service, latch, flag1, 100L)); pool.execute(new TestRunnable(service, latch, flag2, 100L)); latch.await(); Assert.assertFalse(service.isShutdown()); service.shutdown(); Assert.assertTrue(service.isShutdown()); Assert.assertFalse(service.isTerminated()); Assert.assertFalse(service.awaitTermination(1, TimeUnit.MILLISECONDS)); Assert.assertFalse(flag1.get()); Assert.assertFalse(flag2.get()); Assert.assertTrue(service.awaitTermination(1000, TimeUnit.MILLISECONDS)); Assert.assertTrue(service.isShutdown()); Assert.assertTrue(service.isTerminated()); Assert.assertTrue(flag1.get()); Assert.assertTrue(flag2.get()); }