how many threads when jvm starts

B

BILL

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.
 
R

Roedy Green

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
 
S

Stefan Ram

BILL said:
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() ); }}
 
J

John B. Matthews

BILL 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?

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?
 
A

Arne Vajhøj

BILL said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top