### Question:
GlobalEventExecutor extends AbstractEventExecutor { @Override public void execute(Runnable task) { if (task == null) { throw new NullPointerException("task"); } addTask(task); if (!inEventLoop()) { startThread(); } } private  GlobalEventExecutor(); @Override EventExecutorGroup parent(); 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); @Override void execute(Runnable task); @Override ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit); @Override ScheduledFuture<V> schedule(Callable<V> callable, long delay, TimeUnit unit); @Override ScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit); @Override ScheduledFuture<?> scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit); static final GlobalEventExecutor INSTANCE; }### Answer:
@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)); assertThat(e.thread, sameInstance(thread)); 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)); assertThat(e.thread, sameInstance(thread)); }