public class StopThread extends Thread {
    private static boolean stopRequested;
     
    public void run() {
        int i = 0;
        while (!stopRequested)
            i++;
    }
    public static void main(String[] args) {
        Thread background = new StopThread();
        background.start();
        try {Thread.sleep(5);}
        catch (InterruptedException e) {};
        stopRequested = true;
    }
}
