1 package com.twister; 2 3 public class StopTheLoop extends Thread { 4 static StopTheLoop looper; 5 6 static { 7 new StopTheLoop().start(); 8 } 9 10 public static void main(String[] args) { 11 looper = new StopTheLoop(); 12 looper = null; 13 do { 14 System.out.println("Infinite Loop"); 15 } while (looper == null); 16 } 17 18 @Override 19 public void run() { 20 Thread.yield(); 21 try { 22 Thread.sleep(1000); 23 } 24 catch (InterruptedException e) { 25 e.printStackTrace(); 26 } 27 System.exit(0); 28 } 29 }