@Test public void executeUpdateOperation_executionOrderPredictableWhenSingleThreaded_2() throws InterruptedException, ExecutionException { final ExecutorService backgroundExecutor = ExecutorServices.createBackgroundExecutor(); final List<Integer> pool = new ArrayList<Integer>(); final Future<?> f1 = backgroundExecutor.submit(new SleepingRunnable(1, 10, pool)); final Future<?> f5 = backgroundExecutor.submit(new SleepingRunnable(5, 50, pool)); final Future<?> f4 = backgroundExecutor.submit(new SleepingRunnable(4, 10, pool)); final Future<?> f3 = backgroundExecutor.submit(new SleepingRunnable(3, 10, pool)); final Future<?> f2 = backgroundExecutor.submit(new SleepingRunnable(2, 10, pool)); f5.get(); f4.get(); f3.get(); f2.get(); f1.get(); assertThat(pool).isEqualTo(Lists.newArrayList(1, 5, 4, 3, 2)); }
public static ExecutorService createBackgroundExecutor() { final ExecutorService executor = Executors.newSingleThreadExecutor(new DaemonThreadFactory(DEFAULT_BACKGROUND_EXECUTOR_NAME)); BACKGROUND_EXECUTORS.add(executor); return executor; }
ExecutorServices { public static ExecutorService createBackgroundExecutor() { final ExecutorService executor = Executors.newSingleThreadExecutor(new DaemonThreadFactory(DEFAULT_BACKGROUND_EXECUTOR_NAME)); BACKGROUND_EXECUTORS.add(executor); return executor; } }
ExecutorServices { public static ExecutorService createBackgroundExecutor() { final ExecutorService executor = Executors.newSingleThreadExecutor(new DaemonThreadFactory(DEFAULT_BACKGROUND_EXECUTOR_NAME)); BACKGROUND_EXECUTORS.add(executor); return executor; } private  ExecutorServices(); }
ExecutorServices { public static ExecutorService createBackgroundExecutor() { final ExecutorService executor = Executors.newSingleThreadExecutor(new DaemonThreadFactory(DEFAULT_BACKGROUND_EXECUTOR_NAME)); BACKGROUND_EXECUTORS.add(executor); return executor; } private  ExecutorServices(); static ExecutorService createBackgroundExecutor(); static ScheduledExecutorService createScheduler(); static void shutdown(@Nonnull final ExecutorService executorService); static void shutdown(@Nonnull final ExecutorService executorService, @Nonnegative final long duration,
			@Nonnull final TimeUnit unit); static void shutdownAll(); }
ExecutorServices { public static ExecutorService createBackgroundExecutor() { final ExecutorService executor = Executors.newSingleThreadExecutor(new DaemonThreadFactory(DEFAULT_BACKGROUND_EXECUTOR_NAME)); BACKGROUND_EXECUTORS.add(executor); return executor; } private  ExecutorServices(); static ExecutorService createBackgroundExecutor(); static ScheduledExecutorService createScheduler(); static void shutdown(@Nonnull final ExecutorService executorService); static void shutdown(@Nonnull final ExecutorService executorService, @Nonnegative final long duration,
			@Nonnull final TimeUnit unit); static void shutdownAll(); static final long SHUTDOWN_DURATION; }