This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Essentially all JVMs have multiple threads running at startup, but the details vary from implementation to implementation. Typically, there are separate threads dedicated to running the garbage collector and calling finalizers. If the AWT is loaded, then there will be more threads running the event queue and other GUI-related services.
You can call t.getThreadGroup() to get the ThreadGroup for your main thread, and then use one of the enumerate() methods to get a list of those two Threads. You can then print each Thread and see its description. All the JVM-created threads should have a descriptive name so you can tell what they are.
Originally posted by sankar vas: Hi all, This is Extension Q. to post I have Emnumerated as said but still only one Thread as output shows.
Are you the same person who posted the first question? I'm confused.
In any case, this program is totally different than the first one, as it creates a Thread object (presumably MyThread is a subclass of Thread). Thread.activeCount() returns not the exact number of active threads, but an estimate; see the Javadocs for ThreadGroup.activeCount(). That estimate can be higher than the actual number of running threads; in particular, it can include Thread objects created but not yet started. When you call enumerate(), you get only those threads that are actually started.