From 97dbfedc43dbb9e4cc1eb085bc54f4f9b1b85f0e Mon Sep 17 00:00:00 2001 From: Shixiong Zhu Date: Mon, 21 Dec 2015 18:17:17 -0800 Subject: [PATCH] Fix the initialization order in GenericScheduledExecutorService The static `GenericScheduledExecutorService.None` should be initialized before creating any GenericScheduledExecutorService instance. --- .../GenericScheduledExecutorService.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/rx/internal/schedulers/GenericScheduledExecutorService.java b/src/main/java/rx/internal/schedulers/GenericScheduledExecutorService.java index 8d0d5bdec2..82260207ae 100644 --- a/src/main/java/rx/internal/schedulers/GenericScheduledExecutorService.java +++ b/src/main/java/rx/internal/schedulers/GenericScheduledExecutorService.java @@ -35,18 +35,18 @@ public final class GenericScheduledExecutorService implements SchedulerLifecycle private static final String THREAD_NAME_PREFIX = "RxScheduledExecutorPool-"; private static final RxThreadFactory THREAD_FACTORY = new RxThreadFactory(THREAD_NAME_PREFIX); - - /* Schedulers needs acces to this in order to work with the lifecycle. */ - public final static GenericScheduledExecutorService INSTANCE = new GenericScheduledExecutorService(); - - private final AtomicReference executor; - - static final ScheduledExecutorService NONE; + + private static final ScheduledExecutorService NONE; static { NONE = Executors.newScheduledThreadPool(0); NONE.shutdownNow(); } + + /* Schedulers needs acces to this in order to work with the lifecycle. */ + public final static GenericScheduledExecutorService INSTANCE = new GenericScheduledExecutorService(); + private final AtomicReference executor; + private GenericScheduledExecutorService() { executor = new AtomicReference(NONE); start();