Executors (Java Platform SE 8 ) (original) (raw)

Modifier and Type

Method

Description

static [Callable](../../../java/util/concurrent/Callable.html "interface in java.util.concurrent")<[Object](../../../java/lang/Object.html "class in java.lang")>

[callable](../../../java/util/concurrent/Executors.html#callable-java.security.PrivilegedAction-)([PrivilegedAction](../../../java/security/PrivilegedAction.html "interface in java.security")<?> action)

Returns a Callable object that, when called, runs the given privileged action and returns its result.

static [Callable](../../../java/util/concurrent/Callable.html "interface in java.util.concurrent")<[Object](../../../java/lang/Object.html "class in java.lang")>

[callable](../../../java/util/concurrent/Executors.html#callable-java.security.PrivilegedExceptionAction-)([PrivilegedExceptionAction](../../../java/security/PrivilegedExceptionAction.html "interface in java.security")<?> action)

Returns a Callable object that, when called, runs the given privileged exception action and returns its result.

static [Callable](../../../java/util/concurrent/Callable.html "interface in java.util.concurrent")<[Object](../../../java/lang/Object.html "class in java.lang")>

[callable](../../../java/util/concurrent/Executors.html#callable-java.lang.Runnable-)([Runnable](../../../java/lang/Runnable.html "interface in java.lang") task)

Returns a Callable object that, when called, runs the given task and returns null.

static <T> [Callable](../../../java/util/concurrent/Callable.html "interface in java.util.concurrent")<T>

[callable](../../../java/util/concurrent/Executors.html#callable-java.lang.Runnable-T-)([Runnable](../../../java/lang/Runnable.html "interface in java.lang") task, T result)

Returns a Callable object that, when called, runs the given task and returns the given result.

static [ThreadFactory](../../../java/util/concurrent/ThreadFactory.html "interface in java.util.concurrent")

[defaultThreadFactory](../../../java/util/concurrent/Executors.html#defaultThreadFactory--)()

Returns a default thread factory used to create new threads.

static [ExecutorService](../../../java/util/concurrent/ExecutorService.html "interface in java.util.concurrent")

[newCachedThreadPool](../../../java/util/concurrent/Executors.html#newCachedThreadPool--)()

Creates a thread pool that creates new threads as needed, but will reuse previously constructed threads when they are available.

static [ExecutorService](../../../java/util/concurrent/ExecutorService.html "interface in java.util.concurrent")

[newCachedThreadPool](../../../java/util/concurrent/Executors.html#newCachedThreadPool-java.util.concurrent.ThreadFactory-)([ThreadFactory](../../../java/util/concurrent/ThreadFactory.html "interface in java.util.concurrent") threadFactory)

Creates a thread pool that creates new threads as needed, but will reuse previously constructed threads when they are available, and uses the provided ThreadFactory to create new threads when needed.

static [ExecutorService](../../../java/util/concurrent/ExecutorService.html "interface in java.util.concurrent")

[newFixedThreadPool](../../../java/util/concurrent/Executors.html#newFixedThreadPool-int-)(int nThreads)

Creates a thread pool that reuses a fixed number of threads operating off a shared unbounded queue.

static [ExecutorService](../../../java/util/concurrent/ExecutorService.html "interface in java.util.concurrent")

[newFixedThreadPool](../../../java/util/concurrent/Executors.html#newFixedThreadPool-int-java.util.concurrent.ThreadFactory-)(int nThreads,[ThreadFactory](../../../java/util/concurrent/ThreadFactory.html "interface in java.util.concurrent") threadFactory)

Creates a thread pool that reuses a fixed number of threads operating off a shared unbounded queue, using the provided ThreadFactory to create new threads when needed.

static [ScheduledExecutorService](../../../java/util/concurrent/ScheduledExecutorService.html "interface in java.util.concurrent")

[newScheduledThreadPool](../../../java/util/concurrent/Executors.html#newScheduledThreadPool-int-)(int corePoolSize)

Creates a thread pool that can schedule commands to run after a given delay, or to execute periodically.

static [ScheduledExecutorService](../../../java/util/concurrent/ScheduledExecutorService.html "interface in java.util.concurrent")

[newScheduledThreadPool](../../../java/util/concurrent/Executors.html#newScheduledThreadPool-int-java.util.concurrent.ThreadFactory-)(int corePoolSize,[ThreadFactory](../../../java/util/concurrent/ThreadFactory.html "interface in java.util.concurrent") threadFactory)

Creates a thread pool that can schedule commands to run after a given delay, or to execute periodically.

static [ExecutorService](../../../java/util/concurrent/ExecutorService.html "interface in java.util.concurrent")

[newSingleThreadExecutor](../../../java/util/concurrent/Executors.html#newSingleThreadExecutor--)()

Creates an Executor that uses a single worker thread operating off an unbounded queue.

static [ExecutorService](../../../java/util/concurrent/ExecutorService.html "interface in java.util.concurrent")

[newSingleThreadExecutor](../../../java/util/concurrent/Executors.html#newSingleThreadExecutor-java.util.concurrent.ThreadFactory-)([ThreadFactory](../../../java/util/concurrent/ThreadFactory.html "interface in java.util.concurrent") threadFactory)

Creates an Executor that uses a single worker thread operating off an unbounded queue, and uses the provided ThreadFactory to create a new thread when needed.

static [ScheduledExecutorService](../../../java/util/concurrent/ScheduledExecutorService.html "interface in java.util.concurrent")

[newSingleThreadScheduledExecutor](../../../java/util/concurrent/Executors.html#newSingleThreadScheduledExecutor--)()

Creates a single-threaded executor that can schedule commands to run after a given delay, or to execute periodically.

static [ScheduledExecutorService](../../../java/util/concurrent/ScheduledExecutorService.html "interface in java.util.concurrent")

[newSingleThreadScheduledExecutor](../../../java/util/concurrent/Executors.html#newSingleThreadScheduledExecutor-java.util.concurrent.ThreadFactory-)([ThreadFactory](../../../java/util/concurrent/ThreadFactory.html "interface in java.util.concurrent") threadFactory)

Creates a single-threaded executor that can schedule commands to run after a given delay, or to execute periodically.

static [ExecutorService](../../../java/util/concurrent/ExecutorService.html "interface in java.util.concurrent")

[newWorkStealingPool](../../../java/util/concurrent/Executors.html#newWorkStealingPool--)()

Creates a work-stealing thread pool using allavailable processors as its target parallelism level.

static [ExecutorService](../../../java/util/concurrent/ExecutorService.html "interface in java.util.concurrent")

[newWorkStealingPool](../../../java/util/concurrent/Executors.html#newWorkStealingPool-int-)(int parallelism)

Creates a thread pool that maintains enough threads to support the given parallelism level, and may use multiple queues to reduce contention.

static <T> [Callable](../../../java/util/concurrent/Callable.html "interface in java.util.concurrent")<T>

[privilegedCallable](../../../java/util/concurrent/Executors.html#privilegedCallable-java.util.concurrent.Callable-)([Callable](../../../java/util/concurrent/Callable.html "interface in java.util.concurrent")<T> callable)

Returns a Callable object that will, when called, execute the given callable under the current access control context.

static <T> [Callable](../../../java/util/concurrent/Callable.html "interface in java.util.concurrent")<T>

[privilegedCallableUsingCurrentClassLoader](../../../java/util/concurrent/Executors.html#privilegedCallableUsingCurrentClassLoader-java.util.concurrent.Callable-)([Callable](../../../java/util/concurrent/Callable.html "interface in java.util.concurrent")<T> callable)

Returns a Callable object that will, when called, execute the given callable under the current access control context, with the current context class loader as the context class loader.

static [ThreadFactory](../../../java/util/concurrent/ThreadFactory.html "interface in java.util.concurrent")

[privilegedThreadFactory](../../../java/util/concurrent/Executors.html#privilegedThreadFactory--)()

Returns a thread factory used to create new threads that have the same permissions as the current thread.

static [ExecutorService](../../../java/util/concurrent/ExecutorService.html "interface in java.util.concurrent")

[unconfigurableExecutorService](../../../java/util/concurrent/Executors.html#unconfigurableExecutorService-java.util.concurrent.ExecutorService-)([ExecutorService](../../../java/util/concurrent/ExecutorService.html "interface in java.util.concurrent") executor)

Returns an object that delegates all defined ExecutorService methods to the given executor, but not any other methods that might otherwise be accessible using casts.

static [ScheduledExecutorService](../../../java/util/concurrent/ScheduledExecutorService.html "interface in java.util.concurrent")

[unconfigurableScheduledExecutorService](../../../java/util/concurrent/Executors.html#unconfigurableScheduledExecutorService-java.util.concurrent.ScheduledExecutorService-)([ScheduledExecutorService](../../../java/util/concurrent/ScheduledExecutorService.html "interface in java.util.concurrent") executor)

Returns an object that delegates all defined ScheduledExecutorService methods to the given executor, but not any other methods that might otherwise be accessible using casts.