Thread.setDaemon(boolean on) has the following syntax.
public final void setDaemon(boolean on)
In the following code shows how to use Thread.setDaemon(boolean on) method.
class MyThread extends Thread { MyThread() {/*w w w . j a va 2 s . c o m*/ setDaemon(false); } public void run() { boolean d = isDaemon(); System.out.println("daemon = " + d); } } public class Main { public static void main(String[] args) throws Exception { Thread thread = new MyThread(); System.out.println("thread = " + thread.currentThread()); thread.setDaemon(false); thread.start(); } }
The code above generates the following result.