Loading packages/SettingsLib/src/com/android/settingslib/utils/ThreadUtils.java +18 −5 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.settingslib.utils; import android.os.Handler; import android.os.Looper; import java.util.concurrent.Callable; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; Loading Loading @@ -64,11 +65,16 @@ public class ThreadUtils { * @Return A future of the task that can be monitored for updates or cancelled. */ public static Future postOnBackgroundThread(Runnable runnable) { if (sThreadExecutor == null) { sThreadExecutor = Executors.newFixedThreadPool( Runtime.getRuntime().availableProcessors()); return getThreadExecutor().submit(runnable); } return sThreadExecutor.submit(runnable); /** * Posts callable in background using shared background thread pool. * * @Return A future of the task that can be monitored for updates or cancelled. */ public static Future postOnBackgroundThread(Callable callable) { return getThreadExecutor().submit(callable); } /** Loading @@ -78,4 +84,11 @@ public class ThreadUtils { getUiThreadHandler().post(runnable); } private static synchronized ExecutorService getThreadExecutor() { if (sThreadExecutor == null) { sThreadExecutor = Executors.newFixedThreadPool( Runtime.getRuntime().availableProcessors()); } return sThreadExecutor; } } Loading
packages/SettingsLib/src/com/android/settingslib/utils/ThreadUtils.java +18 −5 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.settingslib.utils; import android.os.Handler; import android.os.Looper; import java.util.concurrent.Callable; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; Loading Loading @@ -64,11 +65,16 @@ public class ThreadUtils { * @Return A future of the task that can be monitored for updates or cancelled. */ public static Future postOnBackgroundThread(Runnable runnable) { if (sThreadExecutor == null) { sThreadExecutor = Executors.newFixedThreadPool( Runtime.getRuntime().availableProcessors()); return getThreadExecutor().submit(runnable); } return sThreadExecutor.submit(runnable); /** * Posts callable in background using shared background thread pool. * * @Return A future of the task that can be monitored for updates or cancelled. */ public static Future postOnBackgroundThread(Callable callable) { return getThreadExecutor().submit(callable); } /** Loading @@ -78,4 +84,11 @@ public class ThreadUtils { getUiThreadHandler().post(runnable); } private static synchronized ExecutorService getThreadExecutor() { if (sThreadExecutor == null) { sThreadExecutor = Executors.newFixedThreadPool( Runtime.getRuntime().availableProcessors()); } return sThreadExecutor; } }