Engineering Full Stack Apps with Java and JavaScript
A daemon thread is a background thread and dies when the thread that created it ends.
A thread that is not daemon is called a user thread.
We can make a thread as daemon thread by calling setDaemon (true) on the thread instance.
We can call setDaemon() for a thread only before it starts, else an IllegalThreadStateException will be thrown.
MyThread t1= new MyThread ();
t1.setDaemon(true);
t1.start();
Note: A complete working example will be added soon.