I am learning Executor service and trying to understand how can I share list of data with the threads in the thread pool. My runnable method needs to read the data from the list and process it .
Runnable runnable = () -> {
System.out.println("Inside : " + Thread.currentThread().getName());
process(list.take());
};
ExecutorService executor = Executors.newFixedThreadPool(threadCount);
executorService.submit(runnable);
All the threads in the pool should process different elements from the list only once