This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes How to make a daemon thread Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How to make a daemon thread" Watch "How to make a daemon thread" New topic
Author

How to make a daemon thread

santhosh.R gowda
Ranch Hand

Joined: Apr 06, 2009
Posts: 296
Hi All

I want to write a code to make a daemon thread. That thread should be running in the background every time as and when the system started(Ex-jvm). And also this should execute particular method in the midnight.

regards
santosh

Creativity is nothing but Breaking Rules
Rahul P Kumar
Ranch Hand

Joined: Sep 26, 2009
Posts: 188
probably you need scheduler with this thread. making a thread daemon is easy. look into web.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39575
    
  27
Check out the java.util.Timer and TimerTask classes - this sounds like a perfect application for them (and they can be made to run as background threads).


Ping & DNS - updated with new look and Ping home screen widget
Vadivel Murugesan
Greenhorn

Joined: Jul 19, 2008
Posts: 11
In Java, any thread can be a Daemon thread. Daemon threads are like a service providers for other threads or objects running in the same process as the daemon thread. Daemon threads are used for background supporting tasks and are only needed while normal threads are executing. If normal threads are not running and remaining threads are daemon threads then the interpreter exits.

setDaemon(true/false) ・/b> This method is used to specify that a thread is daemon thread.

public boolean isDaemon() ・ This method is used to determine the thread is daemon thread or not.

The following program demonstrates the Daemon Thread:


Levi<br />SCJP 1.4
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to make a daemon thread
 
Similar Threads
Spawning threads from Servlets?
need clarification on threads
daemon Thread
Java Thread
regarding daemon thread