class HiloSeppuku implements Runnable {
public void run() {
Thread t = Thread.currentThread();
while(true) {
System.out.println("Hilo: " + t);
if (t.isInterrupted()) break; // Seppuku done!
}
}
public static void main(String args[]) {
Thread t = new Thread(new HiloSeppuku());
t.start();
try {
Thread.sleep(4000);
t.interrupt();
Thread.sleep(3000);
t.join();
}
catch (InterruptedException ie) {
}
}
}
Comments