aspose file tools*
The moose likes Threads and Synchronization and the fly likes What does the value 5 do in Executors.newFixedThreadPool(5). Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "What does the value 5 do in Executors.newFixedThreadPool(5)." Watch "What does the value 5 do in Executors.newFixedThreadPool(5)." New topic
Author

What does the value 5 do in Executors.newFixedThreadPool(5).

Sara Brown
Ranch Hand

Joined: Feb 22, 2012
Posts: 55


The number 5 in the bracket, what does it do? I try to put different value but the output looks like the same.

1- How do we know to put what value in the bracket?
2- What is the reason we put a number there?

please help. thank you.
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 9995
    
    7

From the API docs

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.


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What does the value 5 do in Executors.newFixedThreadPool(5).
 
Similar Threads
class question
Constructing Multidimentional Arrays
Dealing with RuntimeException in SCJD
Callable implementation
Calculate the average of an ArrayList