-
public class AndroidExecutors
Copyright 2017 Meniga Iceland Inc.
-
-
Field Summary
Fields Modifier and Type Field Description final static int
CORE_POOL_SIZE
final static int
MAX_POOL_SIZE
final static long
KEEP_ALIVE_TIME
-
Method Summary
Modifier and Type Method Description static ExecutorService
newCachedThreadPool()
Creates a proper Cached Thread Pool. static ExecutorService
newCachedThreadPool(ThreadFactory threadFactory)
Creates a proper Cached Thread Pool. static void
allowCoreThreadTimeout(ThreadPoolExecutor executor, boolean value)
Compatibility helper function for allowCoreThreadTimeOutOnly available on android-9+. static Executor
uiThread()
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.
-
-
-
-