@Test public void testAutomaticStartStop() throws Exception { final TestRunnable task = new TestRunnable(500); e.execute(task); Thread thread = e.thread; assertThat(thread, is(not(nullValue()))); assertThat(thread.isAlive(), is(true)); Thread.sleep(1500); assertThat(thread.isAlive(), is(false)); assertThat(task.ran.get(), is(true)); task.ran.set(false); e.execute(task); assertThat(e.thread, not(sameInstance(thread))); thread = e.thread; Thread.sleep(1500); assertThat(thread.isAlive(), is(false)); assertThat(task.ran.get(), is(true)); }
@Override public void execute(Runnable task) { if (task == null) { throw new NullPointerException("task"); } addTask(task); if (!inEventLoop()) { startThread(); } }
GlobalEventExecutor extends AbstractScheduledEventExecutor { @Override public void execute(Runnable task) { if (task == null) { throw new NullPointerException("task"); } addTask(task); if (!inEventLoop()) { startThread(); } } }
GlobalEventExecutor extends AbstractScheduledEventExecutor { @Override public void execute(Runnable task) { if (task == null) { throw new NullPointerException("task"); } addTask(task); if (!inEventLoop()) { startThread(); } } private  GlobalEventExecutor(); }
GlobalEventExecutor extends AbstractScheduledEventExecutor { @Override public void execute(Runnable task) { if (task == null) { throw new NullPointerException("task"); } addTask(task); if (!inEventLoop()) { startThread(); } } private  GlobalEventExecutor(); int pendingTasks(); @Override boolean inEventLoop(Thread thread); @Override Future<?> shutdownGracefully(long quietPeriod, long timeout, TimeUnit unit); @Override Future<?> terminationFuture(); @Override @Deprecated void shutdown(); @Override boolean isShuttingDown(); @Override boolean isShutdown(); @Override boolean isTerminated(); @Override boolean awaitTermination(long timeout, TimeUnit unit); boolean awaitInactivity(long timeout, TimeUnit unit); @Override void execute(Runnable task); }
GlobalEventExecutor extends AbstractScheduledEventExecutor { @Override public void execute(Runnable task) { if (task == null) { throw new NullPointerException("task"); } addTask(task); if (!inEventLoop()) { startThread(); } } private  GlobalEventExecutor(); int pendingTasks(); @Override boolean inEventLoop(Thread thread); @Override Future<?> shutdownGracefully(long quietPeriod, long timeout, TimeUnit unit); @Override Future<?> terminationFuture(); @Override @Deprecated void shutdown(); @Override boolean isShuttingDown(); @Override boolean isShutdown(); @Override boolean isTerminated(); @Override boolean awaitTermination(long timeout, TimeUnit unit); boolean awaitInactivity(long timeout, TimeUnit unit); @Override void execute(Runnable task); static final GlobalEventExecutor INSTANCE; }