J
Jeff
Is there some mechanism to identify which class or method created a thread?
My application's thread count increases dramatically heavy loads. At
startup, my application creates 5 threads. However, 10 threads are listed
in the active thread enumeration. Now some of those could be supporting
libraries such as log4j. But once it starts processing load, the thread
count jumps to 26, and eventually gets above 150.
I've called Thread(String arg) when the application explicitly creates
threads so that I can identify the threads the application explicitly
creates. The mystery threads all have high identifier names. For example,
At startup, the threads are called:
Thread-1
Thread-2
Thread-3.
Under load, I see:
Thread-760
Thread-1750
1. Does 760 imply there are 759 previous threads?
2. There are always 3 null entries in the enumeration of active threads.
Is this symptom some discrepency between activeCount() and
Thread.enumerate()?
Here's the method I use to count threads:
public static void listThreads() {
int activeCount = Thread.activeCount();
System.out.println("active thread count: " + activeCount);
Thread[] threads = new Thread[activeCount];
Thread.enumerate(threads);
for ( int j = 0 ; j < threads.length ; j ++ ) {
System.out.println("threads["+ j + "]:" + threads[j]);
}
}
Thanks
My application's thread count increases dramatically heavy loads. At
startup, my application creates 5 threads. However, 10 threads are listed
in the active thread enumeration. Now some of those could be supporting
libraries such as log4j. But once it starts processing load, the thread
count jumps to 26, and eventually gets above 150.
I've called Thread(String arg) when the application explicitly creates
threads so that I can identify the threads the application explicitly
creates. The mystery threads all have high identifier names. For example,
At startup, the threads are called:
Thread-1
Thread-2
Thread-3.
Under load, I see:
Thread-760
Thread-1750
1. Does 760 imply there are 759 previous threads?
2. There are always 3 null entries in the enumeration of active threads.
Is this symptom some discrepency between activeCount() and
Thread.enumerate()?
Here's the method I use to count threads:
public static void listThreads() {
int activeCount = Thread.activeCount();
System.out.println("active thread count: " + activeCount);
Thread[] threads = new Thread[activeCount];
Thread.enumerate(threads);
for ( int j = 0 ; j < threads.length ; j ++ ) {
System.out.println("threads["+ j + "]:" + threads[j]);
}
}
Thanks