• Post Reply Bookmark Topic Watch Topic
  • New Topic

JVM threads  RSS feed

 
Manasa Rao
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JVM is supposed to use threads internally when any application is being executed. How do I know the list of all threads that JVM/OS is managing?
For example: I write a "Hello World" program. How do I find out what are the internal threads that JVM manages to execute the above program?
Please help me understand the multithreading concepts.
Thanks in advance,
Manasa
 
Greg Charles
Sheriff
Posts: 3014
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, there's always the main thread, which executes your application. There's a separate one for the garbage collector. If you run a GUI application, there's another handling events. Of course, there will also be any threads you started. Any decent debugger should show you what threads exists. Profilers, like OptomizeIt, can also display this information.
There are probably more low-tech, manual ways to get this information as well. (After all the debuggers and profilers must be getting it from somewhere.) The Thread class has an enumrate() method, which will show you all threads in the same ThreadGroup. You might also make a study of the -X options to the JVM. One of them might make thread information accessible. I prefer to rely on tools though.
 
Manasa Rao
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much. That was very informational.
Manasa
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!