aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/utils/ExecutorUtils.java
diff options
context:
space:
mode:
authorJatin Matani <jatinm@google.com>2015-02-12 00:39:30 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2015-02-12 00:39:30 +0000
commit2a307fdd0abd0a1088bc746eccae87b8d7305dce (patch)
treec316bba9a982a83e80ff0d160adf592fb7ccbbdd /java/src/com/android/inputmethod/latin/utils/ExecutorUtils.java
parent28f9aa1fad2b6cc889af156a3490fe28d098cbbb (diff)
parent4084fa5caeee09ef7993957c5e922dab14c57f3f (diff)
downloadlatinime-2a307fdd0abd0a1088bc746eccae87b8d7305dce.tar.gz
latinime-2a307fdd0abd0a1088bc746eccae87b8d7305dce.tar.xz
latinime-2a307fdd0abd0a1088bc746eccae87b8d7305dce.zip
am 4084fa5c: Refactor content provider code from ContactsDict
* commit '4084fa5caeee09ef7993957c5e922dab14c57f3f': Refactor content provider code from ContactsDict
Diffstat (limited to 'java/src/com/android/inputmethod/latin/utils/ExecutorUtils.java')
-rw-r--r--java/src/com/android/inputmethod/latin/utils/ExecutorUtils.java12
1 files changed, 7 insertions, 5 deletions
diff --git a/java/src/com/android/inputmethod/latin/utils/ExecutorUtils.java b/java/src/com/android/inputmethod/latin/utils/ExecutorUtils.java
index e77f6fd40..50be16072 100644
--- a/java/src/com/android/inputmethod/latin/utils/ExecutorUtils.java
+++ b/java/src/com/android/inputmethod/latin/utils/ExecutorUtils.java
@@ -21,13 +21,14 @@ import com.android.inputmethod.annotations.UsedForTesting;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ThreadFactory;
/**
* Utilities to manage executors.
*/
public class ExecutorUtils {
- static final ConcurrentHashMap<String, ExecutorService> sExecutorMap =
+ static final ConcurrentHashMap<String, ScheduledExecutorService> sExecutorMap =
new ConcurrentHashMap<>();
private static class ThreadFactoryWithId implements ThreadFactory {
@@ -46,13 +47,14 @@ public class ExecutorUtils {
/**
* Gets the executor for the given id.
*/
- public static ExecutorService getExecutor(final String id) {
- ExecutorService executor = sExecutorMap.get(id);
+ public static ScheduledExecutorService getExecutor(final String id) {
+ ScheduledExecutorService executor = sExecutorMap.get(id);
if (executor == null) {
synchronized (sExecutorMap) {
executor = sExecutorMap.get(id);
if (executor == null) {
- executor = Executors.newSingleThreadExecutor(new ThreadFactoryWithId(id));
+ executor = Executors.newSingleThreadScheduledExecutor(
+ new ThreadFactoryWithId(id));
sExecutorMap.put(id, executor);
}
}
@@ -66,7 +68,7 @@ public class ExecutorUtils {
@UsedForTesting
public static void shutdownAllExecutors() {
synchronized (sExecutorMap) {
- for (final ExecutorService executor : sExecutorMap.values()) {
+ for (final ScheduledExecutorService executor : sExecutorMap.values()) {
executor.execute(new Runnable() {
@Override
public void run() {