Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Virtual Machine / July 2003

Tip: Looking for answers? Try searching our database.

Count threads of a Java program

Thread view: 
edw - 24 Jul 2003 21:37 GMT
All,

I'm running quite a big java application on a solaris 8 machine.
All I want to know now is, how many java threads this application has.
Now, I know, that each LWP contains at least one java thread, so I can
make a lower boundary. But I can not tell, how many there really are.
I tried a lot of things like ps -L, or prstat -L ending up with a NLWP
number, but not the actual thread count.
Changing the application is also not an option, as we do not have the
source of it :-(

Is there anyone who can help with this?
Thanx a lot
EDW.
Matthias Ernst - 25 Jul 2003 11:18 GMT
> All,
>
> I'm running quite a big java application on a solaris 8 machine.
> All I want to know now is, how many java threads this application has.

Send a SIGQUIT to the process (kill -QUIT <pid>). A thread dump will be
dumped to stderr or stdout.  No worry, the VM will keep running ! You can
grep 'prio=' | wc -l or somesuch on that dump to count the threads. Apart
from the number, these dumps can be highly interesting for the debugging
reader...

Matthias
Signature

Matthias Ernst
Software Engineer

CoreMedia - Smart Content Technology

edw - 28 Jul 2003 09:17 GMT
> > All,
> >
[quoted text clipped - 8 lines]
>
> Matthias

This is a true operations solution. Worked like a charm. Thanx a lot :-)
edw.
Sami Lakka - 29 Jul 2003 06:10 GMT
If you don't want to use JVMPI or JDI you could just run the program in
debugger that shows the running threads. Graphical debuggers usually has
this functionality (for example Eclipse). You can also use the hprof
profiler
that is distributed with Sun's JVM. Just type Java -Xrunhprof
applicationToBeProfiled.
HProf dumps the profiling data of that application, and as I remember it
also shows
the thread count.

- Sami

> All,
>
[quoted text clipped - 10 lines]
> Thanx a lot
> EDW.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.