views:

63

answers:

2

I am using a networking library which uses a thread pool for delegating tasks to specialized request handlers. In the logs of the library I see the following:

[05.03.2010 16:11:27] [pool-3-thread-9] DEBUG ...
[05.03.2010 16:11:27] [pool-1-thread-447] DEBUG ......
[05.03.2010 16:11:27] [pool-1-thread-447] DEBUG ....
[05.03.2010 16:11:27] [pool-1-thread-440] DEBUG ..

Thread IDs are slowly rising, however memory usage is consistent. Does this mean that a cached thread pool is in use here? That's a fairly big Thread ID, I hope it doesn't mean there's over 400 idle/working threads in the application.

+1  A: 

In the Java source for Thread there is the following code:

private static int threadInitNumber;

private static synchronized int nextThreadNum() {
    return threadInitNumber++;
}

This number is used by the Thread constructor, when users don't specify a name. They do not reuse numbers for terminated/finished threads.

So when memory consumption is equal: it definitely means older Threads are not (fully) reused but terminated or finished.

Pindatjuh
A: 

You may see the stack trace for the process (kill -QUIT process_id on unix ). This should show all the threads for the process.