-
public class AndroidExecutorsCopyright 2017 Meniga Iceland Inc.
-
-
Field Summary
Fields Modifier and Type Field Description final static intCORE_POOL_SIZEfinal static intMAX_POOL_SIZEfinal static longKEEP_ALIVE_TIME
-
Method Summary
Modifier and Type Method Description static ExecutorServicenewCachedThreadPool()Creates a proper Cached Thread Pool. static ExecutorServicenewCachedThreadPool(ThreadFactory threadFactory)Creates a proper Cached Thread Pool. static voidallowCoreThreadTimeout(ThreadPoolExecutor executor, boolean value)Compatibility helper function for allowCoreThreadTimeOutOnly available on android-9+. static ExecutoruiThread()An java.util.concurrent.Executor that executes tasks on the UI thread. -
-
Method Detail
-
newCachedThreadPool
static ExecutorService newCachedThreadPool()
Creates a proper Cached Thread Pool. Tasks will reuse cached threads if availableor create new threads until the core pool is full. tasks will then be queued. If antask cannot be queued, a new thread will be created unless this would exceed max poolsize, then the task will be rejected. Threads will time out after 1 second.
Core thread timeout is only available on android-9+.
-
newCachedThreadPool
static ExecutorService newCachedThreadPool(ThreadFactory threadFactory)
Creates a proper Cached Thread Pool. Tasks will reuse cached threads if availableor create new threads until the core pool is full. tasks will then be queued. If antask cannot be queued, a new thread will be created unless this would exceed max poolsize, then the task will be rejected. Threads will time out after 1 second.
Core thread timeout is only available on android-9+.
- Parameters:
threadFactory- the factory to use when creating new threads
-
allowCoreThreadTimeout
static void allowCoreThreadTimeout(ThreadPoolExecutor executor, boolean value)
Compatibility helper function for allowCoreThreadTimeOut
Only available on android-9+.
- Parameters:
executor- the java.util.concurrent.ThreadPoolExecutorvalue- true if should time out, else false
-
uiThread
static Executor uiThread()
An java.util.concurrent.Executor that executes tasks on the UI thread.
-
-
-
-