I notice that default tomcat 7 thread pool size seems to be 200.
But normal CPU seems have 16 cores.
So only 16 threads can be executed paralleld
Why does tomcat use so much threads.
The number of threads in the pool depends on the parameters you've set for the connector in your conf/server. xml file. By default, Tomcat sets maxThreads to 200, which represents the maximum number of threads allowed to run at any given time.
The default configuration is a core pool size of 1, with unlimited max pool size and unlimited queue capacity. This is roughly equivalent to Executors.
ThreadPool will create maximum of 10 threads to process 10 requests at a time. After process completion of any single Thread, ThreadPool will internally allocate the 11th request to this Thread and will keep on doing the same to all the remaining requests.
Default Java thread stack size is 1 MB for 64-bit JVMs. That is why creating a new thread for each request when requests are frequent and lightweight is a waste of resources. Thread pools can handle thread lifecycle automatically according to the strategy selected on thread pool creation.
For long years many single core computer have been around and were able to run functions in a "pseudo-parallel" mode, that said, you might have 16 threads running in real parallel mode and others running in pseudo parallel.
For more information look at this: Parallel Computing
To answer your question, these threads are useful to process requests, a bunch of them will be used for attending http requests and others will be used on calling the application logic.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With