This week's book giveaway is in the Java in General forum. We're giving away four copies of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 and have ishori Sharan & Adam L Davis on-line! See this thread for details.
I have a scenario where my application has ~12000 threads that are being displayed as stopped in my profiler. However, the memory usage figures shown are very high, and they go on increasing as more threads go in stopped state.
My question is, when a thread goes into stopped state, does it release all resources held by it, or does it hold on to them?
If it holds on, is there a way to free these resources?
Why would the resources be freed? The thread is still alive, and could be woken up at any time. The better question is: Why is there a need to keep 12000 of them around even if though there're stopped? Maybe there's a way that allows the threads to be discarded when they're not used.
If the many threads have finished executing, then the JVM should release the associated Thread objects. If the threads are suspended (naughty), in wait(), waiting for a monitor or something like that, but still alive, then they cannot be released, because they might come back to life at any time.
The Thread objects won't be released if something in your code is holding a reference to them. Perhaps you're storing them all in a collection, or something like that.
Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.