I have a WorkManager+ThreadPool under Glassfish that uses TIMED_WAIT, such as this:
p: thread-pool-1; w: 2018 (TIMED_WAITING):
at java.lang.Object.wait(Native Method)
at com.sun.corba.ee.impl.orbutil.threadpool.WorkQueueImpl.requestWork(WorkQueueImpl.java:171)
at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:528)`
Let’s assume for a moment that the threads do nothing (that is, no Work is ever added). Is there a difference in the CPU usage between having 100 threads in the pool and 3000 threads in the pool?
Our testing shows there isn’t, but I’d like to make sure.
I’d say this is OS-specific; we have thousands of threads running in our Java-server softwares on a Linux-server with NPTL (Native Posix Threading Library), but most of them are “sleeping” most of the time, and the cpu-usage has never been really high, usually between 5-20% (on a single 4-core cpu). I couldn’t find any reference right now, but I’m fairly sure I’ve read that with NPTL, the overhead of sleeping threads is negligible.