Count threads of a Java program

Ask a Question related to Sun Solaris, Design and Development.

  1. #1

    Default Count threads of a Java program

    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.
    edw Guest

  2. Similar Questions and Discussions

    1. Integrating html/java/xml code into flash program
      Ok im fairly new to flash, i wrote myself a webpage using ms frontpage that basicly has a searchbar and go button for the 6 or so major sites that i...
    2. cfexec problem when running certain java program
      Did you find a resolution for this? I'm also looking for a way to use SSH and have run into some problems as well.
    3. calling a java program with shell_exec()
      Hi, I couldn't compile php with java support on Mac OS X so I thought I'd call my java program with shell_exec(). It does work for simple...
    4. To count a number of lines in C++ or Java or ASCII files by exluding white spaces and comments
      Hi all, We have huge files in Java and C++ and I need to count the total number of lines in each of them by excluding white spaces (from the...
    5. problem : SNMP port used when starting my java program
      > I'm trying to send a TRAP PDU using a java SNMP stack can I send SNMP packets using another port???
  3. #2

    Default Re: Count threads of a Java program

    edw wrote:
    > 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
    --
    Matthias Ernst
    Software Engineer

    CoreMedia - Smart Content Technology
    Matthias Ernst Guest

  4. #3

    Default Re: Count threads of a Java program

    In message <qoj0ivccqhgrojff1f8s562c8l0ql0apat@4ax.com>, Roedy Green
    <roedy@mindprod.com> writes
    >On 24 Jul 2003 13:37:25 -0700, [email]edw@gmx.at[/email] (edw) wrote or quoted :
    >
    >>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.
    >
    >You might modify the Thread constructor to add one to a count and
    >display it. Then put your modified class file in rt.jar.
    Write a helper DLL using JVMPI or JVMDI and count the thread creation in
    that. You can printf to the console or put up your own GUI to display
    the details. You'll need to be familiar with C/C++ though.

    The JVMDI also has a high level Java interface, but I couldn't comment
    about this.

    Java tools for Windows (in beta) [url]http://www.softwareverify.com[/url]
    --
    Stephen Kellett
    Object Media Limited [url]http://www.objmedia.demon.co.uk[/url]
    RSI Information: [url]http://www.objmedia.demon.co.uk/rsi.html[/url]
    Stephen Kellett Guest

  5. #4

    Default Re: Count threads of a Java program

    Stephen Kellett <snail@objmedia.demon.co.uk> wrote in message news:<uaDsU8H$RQI$EwgP@objmedia.demon.co.uk>...
    > In message <qoj0ivccqhgrojff1f8s562c8l0ql0apat@4ax.com>, Roedy Green
    > <roedy@mindprod.com> writes
    > >On 24 Jul 2003 13:37:25 -0700, [email]edw@gmx.at[/email] (edw) wrote or quoted :
    > >
    > >>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.
    > >
    > >You might modify the Thread constructor to add one to a count and
    > >display it. Then put your modified class file in rt.jar.
    >
    > Write a helper DLL using JVMPI or JVMDI and count the thread creation in
    > that. You can printf to the console or put up your own GUI to display
    > the details. You'll need to be familiar with C/C++ though.
    >
    > The JVMDI also has a high level Java interface, but I couldn't comment
    > about this.
    >
    > Java tools for Windows (in beta) [url]http://www.softwareverify.com[/url]
    Thanx a lot, but programming is no option here and solaris is not very
    familiar with dlls ;-)

    edw.
    edw Guest

  6. #5

    Default Re: Count threads of a Java program

    Matthias Ernst <matthias.ernst@coremedia.com> wrote in message news:<bfr05t$hoett$1@ID-133822.news.uni-berlin.de>...
    > edw wrote:
    >
    > > 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
    This is a true operations solution. Worked like a charm. Thanx a lot :-)
    edw.
    edw Guest

  7. #6

    Default Re: Count threads of a Java program

    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


    "edw" <edw@gmx.at> wrote in message
    news:84ea18d7.0307240502.70e58f82@posting.google.c om...
    > 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.

    Sami Lakka Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139