title: Simualting ThreadDeath Exception in Java
body: <p>how can i simulate the threaddeath exception in java programming, in what scenario this will occurr, can any one give example, to throw the threaddeath exception.</p>
  
  <p>Thanks:</p>
  
  <pre><code>public class ThreadDeathCatch {
     public static void main(String[] args) {
       try {
         Thread t = new Thread() {
           public void run() {
             try {
               Thread.sleep(2500);
             } catch (Throwable ex)  {
                 ex.printStackTrace();
               System.out.println("Caught in run: " + ex);
             }
           }
         };
         t.start();
         // Give t time to get going...
         Thread.sleep(1000);
         t.stop();        // EXPECT COMPILER WARNING
       } catch (Throwable t) {
         System.out.println("Caught in main: " + t);
       }
     }
   }
  </code></pre>
  
  <p><strong>this is the example to throw Threaddeath, it uses Thread.stop is there any other  wrong scenario where thread death can occur in multithreaded environment without using Thread.stop</strong> </p>
  
  <blockquote>
    <p>Any thoughts ?</p>
  </blockquote>