Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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) {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment