Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ private SchedulerPoolFactory() {
* Starts the purge thread if not already started.
*/
public static void start() {
if (!PURGE_ENABLED) {
return;
}
for (;;) {
ScheduledExecutorService curr = PURGE_THREAD.get();
if (curr != null && !curr.isShutdown()) {
Expand All @@ -78,7 +81,10 @@ public static void start() {
* Stops the purge thread.
*/
public static void shutdown() {
PURGE_THREAD.get().shutdownNow();
ScheduledExecutorService exec = PURGE_THREAD.get();
if (exec != null) {
exec.shutdownNow();
}
POOLS.clear();
}

Expand All @@ -90,10 +96,10 @@ public static void shutdown() {

if (properties.containsKey(PURGE_ENABLED_KEY)) {
purgeEnable = Boolean.getBoolean(PURGE_ENABLED_KEY);
}

if (purgeEnable && properties.containsKey(PURGE_PERIOD_SECONDS_KEY)) {
purgePeriod = Integer.getInteger(PURGE_PERIOD_SECONDS_KEY, purgePeriod);
}
if (purgeEnable && properties.containsKey(PURGE_PERIOD_SECONDS_KEY)) {
purgePeriod = Integer.getInteger(PURGE_PERIOD_SECONDS_KEY, purgePeriod);
}

PURGE_ENABLED = purgeEnable;
Expand All @@ -109,7 +115,7 @@ public static void shutdown() {
*/
public static ScheduledExecutorService create(ThreadFactory factory) {
final ScheduledExecutorService exec = Executors.newScheduledThreadPool(1, factory);
if (exec instanceof ScheduledThreadPoolExecutor) {
if (PURGE_ENABLED && exec instanceof ScheduledThreadPoolExecutor) {
ScheduledThreadPoolExecutor e = (ScheduledThreadPoolExecutor) exec;
POOLS.put(e, exec);
}
Expand Down