File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Default Thread Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Default Thread" Watch "Default Thread" New topic
Author

Default Thread

Ritesh raushan
Ranch Hand

Joined: Aug 29, 2012
Posts: 100
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: 4461
    
    8

You sure you're reading that right? There are two types of thread: daemon and non-daemon.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14338
    
  22

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 8 API documentation
Ritesh raushan
Ranch Hand

Joined: Aug 29, 2012
Posts: 100
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: 100
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: 4461
    
    8

Ritesh raushan wrote: ya i am sure....

Can you give us a reference?
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4181
    
  21

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: 100
for Mathew......webpage
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18882
    
    8

That's a broken link -- would you like to try again?
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4658
    
    5

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: 100
Darryl Burke wrote:
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?
....

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: 6109
    
    6

Ritesh raushan wrote:
Darryl Burke wrote:
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?
....

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