DefaultNoticeableFuture extends FutureTask<T> implements NoticeableFuture<T> { @Override public void set(T t) { super.set(t); } @SuppressWarnings("unchecked")  DefaultNoticeableFuture();  DefaultNoticeableFuture(Callable<T> callable);  DefaultNoticeableFuture(Runnable runnable, T result); @Override boolean addFutureListener(FutureListener<T> futureListener); @Override boolean removeFutureListener(FutureListener<T> futureListener); @Override void set(T t); @Override void setException(Throwable throwable);  }
@Test public void testConstructor() throws Exception { final AtomicBoolean flag = new AtomicBoolean(); DefaultNoticeableFuture<?> defaultNoticeableFuture = new DefaultNoticeableFuture<Object>( new Callable<Object>() { @Override public Object call() { flag.set(true); return flag; } }); defaultNoticeableFuture.run(); Assert.assertSame(flag, defaultNoticeableFuture.get()); Assert.assertTrue(flag.get()); defaultNoticeableFuture = new DefaultNoticeableFuture<Object>( new Runnable() { @Override public void run() { flag.set(false); } }, flag); defaultNoticeableFuture.run(); Assert.assertSame(flag, defaultNoticeableFuture.get()); Assert.assertFalse(flag.get()); }