Freigeben über


Executors.NewFixedThreadPool Method

Definition

Overloads

NewFixedThreadPool(Int32)

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

NewFixedThreadPool(Int32, IThreadFactory)

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.

NewFixedThreadPool(Int32)

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

[Android.Runtime.Register("newFixedThreadPool", "(I)Ljava/util/concurrent/ExecutorService;", "")]
public static Java.Util.Concurrent.IExecutorService? NewFixedThreadPool (int nThreads);
[<Android.Runtime.Register("newFixedThreadPool", "(I)Ljava/util/concurrent/ExecutorService;", "")>]
static member NewFixedThreadPool : int -> Java.Util.Concurrent.IExecutorService

Parameters

nThreads
Int32

the number of threads in the pool

Returns

the newly created thread pool

Attributes

Exceptions

if nThreads <= 0

Remarks

Creates a thread pool that reuses a fixed number of threads operating off a shared unbounded queue. At any point, at most nThreads threads will be active processing tasks. If additional tasks are submitted when all threads are active, they will wait in the queue until a thread is available. If any thread terminates due to a failure during execution prior to shutdown, a new one will take its place if needed to execute subsequent tasks. The threads in the pool will exist until it is explicitly ExecutorService#shutdown shutdown.

Java documentation for java.util.concurrent.Executors.newFixedThreadPool(int).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

NewFixedThreadPool(Int32, IThreadFactory)

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.

[Android.Runtime.Register("newFixedThreadPool", "(ILjava/util/concurrent/ThreadFactory;)Ljava/util/concurrent/ExecutorService;", "")]
public static Java.Util.Concurrent.IExecutorService? NewFixedThreadPool (int nThreads, Java.Util.Concurrent.IThreadFactory? threadFactory);
[<Android.Runtime.Register("newFixedThreadPool", "(ILjava/util/concurrent/ThreadFactory;)Ljava/util/concurrent/ExecutorService;", "")>]
static member NewFixedThreadPool : int * Java.Util.Concurrent.IThreadFactory -> Java.Util.Concurrent.IExecutorService

Parameters

nThreads
Int32

the number of threads in the pool

threadFactory
IThreadFactory

the factory to use when creating new threads

Returns

the newly created thread pool

Attributes

Exceptions

if threadFactory is null

if nThreads <= 0

Remarks

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. At any point, at most nThreads threads will be active processing tasks. If additional tasks are submitted when all threads are active, they will wait in the queue until a thread is available. If any thread terminates due to a failure during execution prior to shutdown, a new one will take its place if needed to execute subsequent tasks. The threads in the pool will exist until it is explicitly ExecutorService#shutdown shutdown.

Java documentation for java.util.concurrent.Executors.newFixedThreadPool(int, java.util.concurrent.ThreadFactory).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to