| Author |
Default Thread
|
Ritesh raushan
Ranch Hand
Joined: Aug 29, 2012
Posts: 97
|
|
how many default threads in java..
in oracle docs mention that only one thread i.e main thread..
but in jvm specification mention that two default threads..i.e daemon and non-daemon...
and how we proved that default thread is created before main()...
|
 |
Matthew Brown
Bartender
Joined: Apr 06, 2010
Posts: 3793
|
|
|
You sure you're reading that right? There are two types of thread: daemon and non-daemon.
|
 |
Jesper de Jong
Java Cowboy
Bartender
Joined: Aug 16, 2005
Posts: 12921
|
|
Daemon and non-daemon are types of threads, not actual instances of threads. Normally the JVM will exit when all non-daemon threads have stopped. Daemon threads automatically get stopped when the JVM exists.
How many threads there are in an "empty" JVM is implementation-dependent. There is one thread that runs the main() method, and there might be one or more other threads for example for garbage collection or other background tasks.
Java code always runs in a thread. So the thread that runs the main() method must be created before the main() method runs, otherwise there would be no way to run the method.
|
Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
|
 |
Ritesh raushan
Ranch Hand
Joined: Aug 29, 2012
Posts: 97
|
|
|
then if anyone ask that how many default threads created by jvm then what will i given..
|
 |
Ritesh raushan
Ranch Hand
Joined: Aug 29, 2012
Posts: 97
|
|
Matthew Brown wrote:You sure you're reading that right? There are two types of thread: daemon and non-daemon.
ya i am sure....
|
 |
Matthew Brown
Bartender
Joined: Apr 06, 2010
Posts: 3793
|
|
Ritesh raushan wrote: ya i am sure....
Can you give us a reference?
|
 |
Steve Luke
Bartender
Joined: Jan 28, 2003
Posts: 3036
|
|
Ritesh raushan wrote:then if anyone ask that how many default threads created by jvm then what will i given..
That it is implementation dependent, there will be a minimum of one, but usually more.
|
Steve
|
 |
Ritesh raushan
Ranch Hand
Joined: Aug 29, 2012
Posts: 97
|
|
|
for Mathew......webpage
|
 |
Paul Clapham
Bartender
Joined: Oct 14, 2005
Posts: 16483
|
|
|
That's a broken link -- would you like to try again?
|
 |
Darryl Burke
Bartender
Joined: May 03, 2008
Posts: 4165
|
|
Ritesh raushan wrote:for Mathew...... webpage
I don't see anything about daemon and non-daemon threads in http://docs.oracle.com/javase/tutorial/essential/concurrency/procthread.html
Or was that some other page you were trying to link to?
|
 |
Ritesh raushan
Ranch Hand
Joined: Aug 29, 2012
Posts: 97
|
|
....
i know there is no daemon and non-daemon thread you should be read jvm specification where declared......
|
 |
Jeff Verdegan
Bartender
Joined: Jan 03, 2004
Posts: 5868
|
|
Ritesh raushan wrote:
....
i know there is no daemon and non-daemon thread you should be read jvm specification where declared......
You said: "in jvm specification mention that two default threads"
However, you have not provided a link to where it says that in the JVM spec. The link you provided (http://docs.oracle.com/javase/tutorial/essential/.../procthread.html) is not valid, and even if you filled in the "..." part, would not point to the JVM spec.
If you're making a claim that the JVM spec says something, then you need to provide a valid link to the part of the JVM spec that supports your claim.
|
 |
 |
|
|
subject: Default Thread
|
|
|