0

I am working in a Java project and I have some doubts about the server side.

I have a class, which will have multiples instances (one instance for each client request). In this class, there are 4 different tasks to do, so I have create a ThreadPool with 4 Threads, but my doubt is if the executor has to be static, because I should call a Listener to kill the threads when the server stop, right ?

ExecutorService executor = Executors.newFixedThreadPool(4);

Thank you.

1 Answers1

0

Can you please see if this can be moved to shared thread pool instantiating the ThreadPoolExecutor using public static

If new threads are created for each request, then the server might eventually run out of threads