As said in javadoc
Threads in the pool will exist until it is explicitly disabled ExecutorService#shutdown()
If I have a web application on Tomcat. At startup, creates a fixed pool of threads. I also researched
public static void main(String ... strings) { ExecutorService s = Executors.newFixedThreadPool(2); s.submit(new Runnable() { public void run() { System.out.println("zzz"); } }); }
that the threads in the above example do not exist until I send them to the ExecutorService. When the main method ends, I see a javaw.exe in the process list of the manger task (win 7 os). Therefore, I assume that the jvm instance that runs this example still exists. When I add s.shutdown() - there is no java process in the process list.
Question 1 : when tomcat suddenly stops due to some errors, will the java process freeze in memory (if previously some tasks were sent to the thread pool mentioned above)
Question 2 : if the answer to the previous question is yes, are there ways to make threads in the pool a deban, or maybe there are some ways to handle such tomcat / myapp stops to call ExecutorService#shutdown()
source share