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

Daemon thread

Sivasubramaniam.N Natarajan.P
Greenhorn

Joined: Mar 14, 2007
Posts: 1
hai
what you mean by a Daemon? give an example , anybody is there to share this question?
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Hi, welcome to the ranch!

Read through the JavaDoc for Thread and see what it says about Daemon. It's kind of confusing, so come back and tell us what you think it said or where it left you confused.


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
pradeep boora
Greenhorn

Joined: Oct 16, 2006
Posts: 1
daemon thread are threads which keep on running in background.
For example main thread( for main method ) is daemon thread. It initiates another user threads
saikrishna cinux
Ranch Hand

Joined: Apr 16, 2005
Posts: 689
deamon threads are low priority threads they run internally when JVM starts


A = HARDWORK B = LUCK/FATE If C=(A+B) then C=SUCCESSFUL IN LIFE else C=FAILURE IN LIFE
SCJP 1.4
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42930
    
  68
deamon threads are low priority threads they run internally when JVM starts


No. While there are daemon threads that are low priority, and which are started when the JVM starts, any thread can be a daemon. Its priority and how it got started have nothing to do with whether or not it's a daemon.
[ March 16, 2007: Message edited by: Ulf Dittmer ]
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 19070
    
  40

Since the original poster doesn't seem to want to take a guess at what a Daemon thread is, let's clarify this...

For the most part, there is no real difference between a daemon thread and a user thread. They both are started with the start() method, they both terminate when the run() method terminates, they both can use synchronization, condition variables, and other threading features, you may set a priority with either, you may deadlock them, etc. etc.

The difference is in how the JVM behaves with daemon threads. A daemon thread is assumed to support user threads. So when there are no more user threads running in the JVM -- meaning only daemon threads are running -- then the JVM terminates. That's it !!


Also... the main thread (thread that calls the main method) is definitely not a daemon thread.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Daemon thread