• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Default Thread

 
Ritesh raushan
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4565
8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You sure you're reading that right? There are two types of thread: daemon and non-daemon.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15205
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ritesh raushan
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
then if anyone ask that how many default threads created by jvm then what will i given..
 
Ritesh raushan
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4565
8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ritesh raushan wrote: ya i am sure....

Can you give us a reference?
 
Steve Luke
Bartender
Posts: 4181
21
IntelliJ IDE Java Python
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ritesh raushan
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
for Mathew......webpage
 
Paul Clapham
Sheriff
Pie
Posts: 20719
30
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's a broken link -- would you like to try again?
 
Darryl Burke
Bartender
Posts: 5125
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic