NoticeableThreadPoolExecutor extends BaseNoticeableExecutorService { @Override public boolean awaitTermination(long timeout, TimeUnit timeUnit) throws InterruptedException { long startTime = System.currentTimeMillis(); if (!_dispatcherThreadPoolExecutor.awaitTermination( timeout, timeUnit)) { return false; } timeout -= timeUnit.convert( System.currentTimeMillis() - startTime, TimeUnit.MILLISECONDS); return _workerThreadPoolExecutor.awaitTermination(timeout, timeUnit); } NoticeableThreadPoolExecutor(
		int corePoolSize, int maximumPoolSize, long keepAliveTime,
		TimeUnit timeUnit, BlockingQueue<Runnable> blockingQueue,
		ThreadFactory threadFactory,
		RejectedExecutionHandler rejectedExecutionHandler,
		ThreadPoolHandler threadPoolHandler); @Override boolean awaitTermination(long timeout, TimeUnit timeUnit); @Override void execute(Runnable runnable); int getActiveCount(); long getCompletedTaskCount(); int getCorePoolSize(); int getLargestPoolSize(); int getMaximumPoolSize(); int getPendingTaskCount(); int getPoolSize(); @Override boolean isShutdown(); @Override boolean isTerminated(); void setCorePoolSize(int corePoolSize); void setMaximumPoolSize(int maximumPoolSize); @Override synchronized void shutdown(); @Override synchronized List<Runnable> shutdownNow(); @Override NoticeableFuture<Void> terminationNoticeableFuture();  }
@Test public void testAwaitTermination() throws InterruptedException { NoticeableThreadPoolExecutor noticeableThreadPoolExecutor = new NoticeableThreadPoolExecutor( 1, 1, 1, TimeUnit.NANOSECONDS, new LinkedBlockingQueue<>(), new MethodNameThreadFactory(), (runnable, threadPoolExecutor) -> { }, new ThreadPoolHandlerAdapter()); Assert.assertFalse( noticeableThreadPoolExecutor.awaitTermination( 1, TimeUnit.NANOSECONDS)); ThreadPoolExecutor dispatcherThreadPoolExecutor = ReflectionTestUtil.getFieldValue( noticeableThreadPoolExecutor, "_dispatcherThreadPoolExecutor"); dispatcherThreadPoolExecutor.shutdown(); Assert.assertFalse( noticeableThreadPoolExecutor.awaitTermination( 1, TimeUnit.NANOSECONDS)); noticeableThreadPoolExecutor.shutdown(); Assert.assertTrue( noticeableThreadPoolExecutor.awaitTermination( 10, TimeUnit.MINUTES)); }