Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > how many threads when jvm starts

Reply
Thread Tools

how many threads when jvm starts

 
 
BILL
Guest
Posts: n/a
 
      07-31-2008
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.

 
Reply With Quote
 
 
 
 
Roedy Green
Guest
Posts: n/a
 
      07-31-2008
On Wed, 30 Jul 2008 19:53:29 -0700 (PDT), BILL <(E-Mail Removed)>
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
 
Reply With Quote
 
 
 
 
Stefan Ram
Guest
Posts: n/a
 
      07-31-2008
BILL <(E-Mail Removed)> 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() ); }}

 
Reply With Quote
 
John B. Matthews
Guest
Posts: n/a
 
      07-31-2008
In article
<(E-Mail Removed)>,
BILL <(E-Mail Removed)> 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
 
Reply With Quote
 
Arne Vajh°j
Guest
Posts: n/a
 
      08-01-2008
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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
How many threads are too many? rbt Python 1 06-11-2005 11:03 PM
How many threads is too many? peelman Java 12 01-15-2005 07:37 AM
Instant Messenger starts when Outlook Express 6 starts no matter what is checked! Route9w Computer Support 11 07-08-2004 01:13 PM
Re: Handling both MS JVM and Sun JVM Kevin Hooke Java 2 09-02-2003 05:31 AM



Advertisments