File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

Daemon Thread

Salman Riaz
Ranch Hand

Joined: Jul 24, 2003
Posts: 53
What is Daemon thread?
What happens when we run more then one program simultaniouly with one main JVM thread.
Can someone explain plz!!!
Cindy Glass
"The Hood"

Joined: Sep 29, 2000
Posts: 8521
Moving to the Threads Forum.
This forum is for management issues relating to the JavaRanch site itself.
[ August 06, 2003: Message edited by: Cindy Glass ]

"JavaRanch, where the deer and the Certified play" - David O'Meara
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24195

Weird -- someone else just asked "what are daemon threads" this morning.
The definition of a daemon thread is just this: if all the threads running in a JVM are daemon threads, the JVM will exit. That's it. So if you want to create a "background" thread to do some repetitive task, but you want your program to exit as soon as main() returns, then make that background thread be a daemon thread.
As far as your second question: is it "What happens when you run multiple JVMs?" or "What happens when you run multiple threads in one JVM?" In either case, nothing remarkable; if you understand what a JVM is and what a Thread is, you should already know the answers.

[Jess in Action][AskingGoodQuestions]
I agree. Here's the link:
subject: Daemon Thread
jQuery in Action, 3rd edition