class Mits implements Runnable {
public static void main (
String args [ ] ) {
Thread tx = new Thread ( new Mits ( ) , " Krux " ) ;
tx . start ( ) ;
System . out . println ( " Terminated " ) ;
}
public void run ( ) {
try
{
Thread . currentThread ( ) . setDaemon ( true ) ;
Thread . sleep ( 10000 ) ;
}
catch (InterruptedException e) { }
}
};
The output is:
Terminated
Exception in thread " Krux " java.lang.IllegalThreadStateException
at java.lang.Thread.setDaemon(Unknown Source)
at Mits.run(Mits.java:12)
at java.lang.Thread.run(Unknown Source)
Why this exception comes???