From e157d45d3919a6b25b16ccb6ee13a4f8c7b91058 Mon Sep 17 00:00:00 2001 From: Anthony Restaino Date: Sun, 27 Sep 2015 11:58:58 -0400 Subject: [PATCH] Use executorservice instead of plain executor to facilitate shutdown --- .../main/java/acr/browser/lightning/async/AsyncExecutor.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/acr/browser/lightning/async/AsyncExecutor.java b/app/src/main/java/acr/browser/lightning/async/AsyncExecutor.java index e5b5dde..2ffb97a 100644 --- a/app/src/main/java/acr/browser/lightning/async/AsyncExecutor.java +++ b/app/src/main/java/acr/browser/lightning/async/AsyncExecutor.java @@ -6,6 +6,7 @@ import android.util.Log; import java.util.ArrayDeque; import java.util.Queue; import java.util.concurrent.Executor; +import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.RejectedExecutionException; @@ -17,7 +18,7 @@ public class AsyncExecutor implements Executor { private static final String TAG = AsyncExecutor.class.getSimpleName(); private static AsyncExecutor INSTANCE = new AsyncExecutor(); private Queue mQueue = new ArrayDeque<>(1); - private Executor mExecutor = Executors.newFixedThreadPool(4); + private ExecutorService mExecutor = Executors.newFixedThreadPool(4); private AsyncExecutor() {} @@ -35,6 +36,7 @@ public class AsyncExecutor implements Executor { @Override protected void finalize() throws Throwable { + mExecutor.shutdownNow(); super.finalize(); }