title: How can i make the main Thread as Daemon Thread in java?
body: <p>I want to make the main thread as daemon thread but it show me <code>IllegalThreadStateException</code>.
  Is there any way to do that?</p>
  <pre><code>public class DeamonThreads {
  
      public static void main(String[] args) {
          System.out.println(&quot;Main Started&quot;);
          System.out.println(&quot;Thread type deamon = &quot; + Thread.currentThread().isDaemon());
          Thread.currentThread().setDaemon(true);
          System.out.println(&quot;Thread type deamon = &quot; + Thread.currentThread().isDaemon());
          System.out.println(&quot;Main End&quot;);
      
      }
  }
  </code></pre>
  <p>Output</p>
  <pre><code>Main Started
  Thread type deamon = false
  Exception in thread &quot;main&quot; java.lang.IllegalThreadStateException
       at java.lang.Thread.setDaemon(Thread.java:1367)
       at com.threads.DeamonThreads.main(DeamonThreads.java:8)
  </code></pre>