newSingleThreadExecutor() method in Executors Class

Viewed 849

The definition for above method is " Creates an Executor that uses a single worker thread operating off an unbounded queue."

I have seen examples which uses above method for "execute multiple instances of a method with different inputs in parallel" by adding different tasks in data structure like "Set" or "List" and calling method invokeAll()

Here I am confused about one thing : If the above method creates only a single worker thread, How is it possible to run the tasks in parallel ?

Of course, there are other methods like newCachedThreadPool(), newFixedThreadPool(int numberOfThreads)- Here many number of threads are created to run in parallel, if needed.

1 Answers
Related