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

muthu muruges
Ranch Hand

Joined: Feb 28, 2003
Posts: 70
Whether the daemon thread will be GCed if it comes out the run method provided the main thread keep on running?
Jim Yingst

Joined: Jan 30, 2000
Posts: 18671
Yes. Well as usualy, there are no guarantees regarding GC, and if you have saved a reference to the thread somewhere, you certainly my prevent GC. But in general, once a thread completes its run method it will be eligible for GC (unless there are other references somewhere). Being a daemon thread does not change this.

"I'm not back." - Bill Harding, Twister
I agree. Here's the link:
subject: Daemon thread