View Javadoc
1   
2   public class UselessCurrentThread implements Runnable {
3   	private Thread unknownThread;
4   
5   	public UselessCurrentThread(Thread t) {
6   		unknownThread = t;
7   	}
8   
9   	public void run() {
10  		try {
11  			// The first should be ok, the next two are silly, the third is
12  			// wrong
13  			while (!Thread.interrupted()) {
14  				System.out.println("huh?");
15  				Thread.sleep(10000);
16  			}
17  
18  			while (!Thread.currentThread().interrupted()) {
19  				System.out.println("huh?");
20  				Thread.sleep(10000);
21  			}
22  
23  			Thread t = Thread.currentThread();
24  			while (!t.interrupted()) {
25  				System.out.println("huh?");
26  				Thread.sleep(10000);
27  			}
28  
29  			while (!unknownThread.interrupted()) {
30  				System.out.println("huh?");
31  				Thread.sleep(10000);
32  			}
33  		} catch (InterruptedException ie) {
34  			System.out.println("Oh, ok");
35  		}
36  	}
37  }