Today in this article we will see some of threads pool available in "Executors" Factory-
Public static ExecutorService
NewFixedThreadPool (int nThreads)
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 shutdown.
Public static ScheduledExecutorService
NewScheduledThreadPool (int corePoolSize)
Creates a thread pool that can schedule commands to run after a given delay, or to execute periodically.
Public static ExecutorService newCachedThreadPool ()
Creates a thread pool that creates new threads as needed, but will reuse previously constructed threads when they are available. these pools will typically improve the performance of programs that execute implements short-lived asynchronous tasks. callto execute will reuse previusly constructed threads if available. if no existing thread is available, a new thread will be created and added to the pool. threads that have not been used for sixty seconds are terminated and removed from the cache. thus, a pool that remains idle for long enough will not consume any resources. note that pools with similar properties but different details (for example, timeout parameters) may be created using ThreadPoolExecutor constructors.
Public static ExecutorService newSingleThreadExecutor ()
Creates an Executor that uses a single worker thread operating off an unbounded queue. (Note however that if this single thread terminates due to a failure during execution prior to shutdown, a new one will take its place if needed to execute subsequent tasks .) tasks are guaranteed to execute sequentially, and no more than one task will be active at any given time. unlike the otherwise equivalent newFixedThreadPool (1) the returned executor is guaranteed not to be rewritable able to use additional threads.
Public static ExecutorService newSingleThreadExecutor ()
Creates an Executor that uses a single worker thread operating off an unbounded queue. (Note however that if this single thread terminates due to a failure during execution prior to shutdown, a new one will take its place if needed to execute subsequent tasks .) tasks are guaranteed to execute sequentially, and no more than one task will be active at any given time. unlike the otherwise equivalent newFixedThreadPool (1) the returned executor is guaranteed not to be rewritable able to use additional threads.
Author: silence is gold