how many threads when jvm starts

Discussion in 'Java' started by BILL, Jul 31, 2008.

  1. BILL

    BILL Guest

    Newbie question...

    when we start a simpel java program (no multiple thread), do we have a
    way to know how many threads the jvm will create... in other words,
    what default threads does the jvm have? do we have a way to get some
    infomation of those threads progammatically?

    Thanks.
     
    BILL, Jul 31, 2008
    #1
    1. Advertising

  2. BILL

    Roedy Green Guest

    On Wed, 30 Jul 2008 19:53:29 -0700 (PDT), BILL <>
    wrote, quoted or indirectly quoted someone who said :

    >Newbie question...
    >
    >when we start a simpel java program (no multiple thread), do we have a
    >way to know how many threads the jvm will create... in other words,
    >what default threads does the jvm have? do we have a way to get some
    >infomation of those threads progammatically?


    You can abort java.exe by hitting ctrl-C. You can abort and get a dump
    of what was going on at the time with the threads with
    Ctrl+Shift+Break. For anything fancier, you will probably need a
    debugger.

    I vaguely recall some simple tool that showed me what was going on
    with threads. There at least half a dozen of them even in a "single
    thread" app.

    Check out the Java.exe command parms to see if there is something.

    See http://mindprod.com/jgloss/javaexe.html


    --

    Roedy Green Canadian Mind Products
    The Java Glossary
    http://mindprod.com
     
    Roedy Green, Jul 31, 2008
    #2
    1. Advertising

  3. BILL

    Stefan Ram Guest

    BILL <> writes:
    >when we start a simpel java program (no multiple thread), do we have a
    >way to know how many threads the jvm will create... in other words,
    >what default threads does the jvm have? do we have a way to get some
    >infomation of those threads progammatically?


    You can print an estimate of the number of active threads in
    the current thread's thread group and its subgroups.

    public class Main
    {
    public static void main( final java.lang.String[] args )
    {
    java.lang.System.out.println
    (
    java.lang.Thread.activeCount() ); }}
     
    Stefan Ram, Jul 31, 2008
    #3
  4. In article
    <>,
    BILL <> wrote:

    > Newbie question...
    >
    > when we start a simpel java program (no multiple thread), do we have a
    > way to know how many threads the jvm will create... in other words,
    > what default threads does the jvm have? do we have a way to get some
    > infomation of those threads progammatically?


    Top shows the total thread count: <http://www.unixtop.org/>

    The NetBeans IDE profiler gives detailed information on each thread.

    On Mac OS, there's a nice graphical tool in /Developer called Thread
    Viewer.

    Thread.currentThread() gives you a reference to the current thread:

    <http://java.sun.com/javase/6/docs/api/java/lang/Thread.html>

    What are you trying to accomplish?

    --
    John B. Matthews
    trashgod at gmail dot com
    home dot woh dot rr dot com slash jbmatthews
     
    John B. Matthews, Jul 31, 2008
    #4
  5. BILL

    Arne Vajhøj Guest

    BILL wrote:
    > when we start a simpel java program (no multiple thread), do we have a
    > way to know how many threads the jvm will create... in other words,
    > what default threads does the jvm have? do we have a way to get some
    > infomation of those threads progammatically?


    Not really.

    The JVM may start a number of housekeeping threads. The number will
    depend on JVM, OS, versions of both, various XX options etc..

    You can easily get information about the threads that your app starts,
    but if you need to find info about the other ones then I think you will
    need to use JNI and some native code.

    Why do you care ?

    Arne
     
    Arne Vajhøj, Aug 1, 2008
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kevin Hooke

    Re: Handling both MS JVM and Sun JVM

    Kevin Hooke, Aug 26, 2003, in forum: Java
    Replies:
    2
    Views:
    884
  2. Lasse
    Replies:
    1
    Views:
    709
    Jon A. Cruz
    Jan 5, 2004
  3. peelman

    How many threads is too many?

    peelman, Jan 13, 2005, in forum: Java
    Replies:
    12
    Views:
    856
    Esmond Pitt
    Jan 15, 2005
  4. rbt
    Replies:
    1
    Views:
    363
  5. Casey Hawthorne
    Replies:
    1
    Views:
    491
    Robert Klemme
    Oct 27, 2006
Loading...

Share This Page