Client and backend. This class is shared: the same code is compiled into your app and into your server, so everything on this page works in both.
public class Executors
- Object
- Executors
Factories for the executor services.
Where a task runs
On the pool’s own threads, never on the UI thread. A task that touches
the user interface hands that part back, the way desktop code does with
SwingUtilities.invokeLater or Platform.runLater.
Workers are started when a task first needs one and share one queue: a
task goes to whichever worker is free. A fixed pool keeps its workers
until it is shut down; a cached pool starts one whenever none is free and
lets one go after a minute without work, as the JDK’s do. The overloads
that take a ThreadFactory make their workers with it.
Waiting
Future.get() and awaitTermination on the UI thread wait through
JdkHost.blockUi, so events keep being dispatched.
The work stealing pools are fixed pools.
Methods
Inherited methods
Method details
newFixedThreadPool
public static ExecutorService newFixedThreadPool(int nThreads)newFixedThreadPool
public static ExecutorService newFixedThreadPool(int nThreads, ThreadFactory threadFactory)newSingleThreadExecutor
public static ExecutorService newSingleThreadExecutor()newSingleThreadExecutor
public static ExecutorService newSingleThreadExecutor(ThreadFactory threadFactory)newCachedThreadPool
public static ExecutorService newCachedThreadPool()newCachedThreadPool
public static ExecutorService newCachedThreadPool(ThreadFactory threadFactory)newWorkStealingPool
public static ExecutorService newWorkStealingPool()newWorkStealingPool
public static ExecutorService newWorkStealingPool(int parallelism)newScheduledThreadPool
public static ScheduledExecutorService newScheduledThreadPool(int corePoolSize)newScheduledThreadPool
public static ScheduledExecutorService newScheduledThreadPool(int corePoolSize, ThreadFactory threadFactory)newSingleThreadScheduledExecutor
public static ScheduledExecutorService newSingleThreadScheduledExecutor()newSingleThreadScheduledExecutor
public static ScheduledExecutorService newSingleThreadScheduledExecutor(ThreadFactory threadFactory)defaultThreadFactory
public static ThreadFactory defaultThreadFactory()pool-N-thread-M.callable
public static <T> Callable<T> callable(Runnable task, T result)Callable that runs task and answers result.callable
public static Callable<Object> callable(Runnable task)