This may not answer the question, but at least help understand what's going on. To get an accurate sample of the threads, get the list form within your app. (Instead of from the debugging tools.)
JVM w/o Instrumentation
- Thread: main
- Thread: Reference Handler
- Thread: Signal Dispatcher
- Thread: Attach Listener
- Thread: Finalizer
JVM w/ Instrumentation (jconsole)
- Thread: main
- Thread: JMX server connection timeout 12
- Thread: RMI TCP Connection(1)-10.1.100.40
- Thread: RMI TCP Connection(2)-10.1.100.40
- Thread: Finalizer
- Thread: Reference Handler
- Thread: RMI Scheduler(0)
- Thread: Signal Dispatcher
- Thread: RMI TCP Accept-0
- Thread: Attach Listener
Experiment
- Execute the following code
- Launch jconsole and connect to that jvm
public class JVM {
public static void main(String... args) throws InterruptedException {
for (java.util.Enumeration<?> e = System.getProperties().propertyNames(); e.hasMoreElements();) {
String prp = (String) e.nextElement();
if (prp.startsWith("java.vm") || prp.startsWith("os.")) {
System.out.format("[%s]=%s%n", prp, System.getProperty(prp));
}
}
java.text.DateFormat df = new java.text.SimpleDateFormat("HH:mm:ss.SSS");
for(;;) {
System.out.format("%s Sampling current threads...%n", df.format(new java.util.Date()));
java.util.Map<Thread, StackTraceElement[]> stacks = Thread.getAllStackTraces();
System.out.format("> Thread Count: %d%n", stacks.size());
for (java.util.Map.Entry<Thread, StackTraceElement[]> entry : stacks.entrySet()) {
Thread thread = entry.getKey();
StackTraceElement[] stack = entry.getValue();
System.out.format("> Thread: %s%n", thread.getName());
// Throwable t = new Throwable("Thread: " + thread.getName());
// t.setStackTrace(stack);
// t.printStackTrace(System.out);
}
java.util.concurrent.TimeUnit.SECONDS.sleep(10);
}
}
}
Output
[java.vm.version]=16.2-b04
[java.vm.vendor]=Sun Microsystems Inc.
[java.vm.name]=Java HotSpot(TM) Client VM
[java.vm.specification.name]=Java Virtual Machine Specification
[os.arch]=x86
[java.vm.specification.vendor]=Sun Microsystems Inc.
[os.name]=Windows XP
[os.version]=5.1
[java.vm.specification.version]=1.0
[java.vm.info]=mixed mode, sharing
14:03:49.199 Sampling current threads...
> Thread Count: 5
> Thread: main
> Thread: Reference Handler
> Thread: Signal Dispatcher
> Thread: Attach Listener
> Thread: Finalizer
14:03:59.200 Sampling current threads...
> Thread Count: 10
> Thread: main
> Thread: JMX server connection timeout 12
> Thread: RMI TCP Connection(1)-10.1.100.40
> Thread: RMI TCP Connection(2)-10.1.100.40
> Thread: Finalizer
> Thread: Reference Handler
> Thread: RMI Scheduler(0)
> Thread: Signal Dispatcher
> Thread: RMI TCP Accept-0
> Thread: Attach Listener
jstack
orjvisualvm
(there exist other tools as well). – Twum