Advertisement
gastaojunior

Java Thread

Jun 27th, 2011
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.41 KB | None | 0 0
  1. public class SimpleThread extends Thread {
  2.     public SimpleThread(String str) {
  3.         super(str);
  4.     }
  5.     public void run() {
  6.         for (int i = 0; i < 10; i++) {
  7.             System.out.println(i + " " + getName());
  8.             try {
  9.                 sleep((long)(Math.random() * 1000));
  10.             } catch (InterruptedException e) {}
  11.         }
  12.         System.out.println("DONE! " + getName());
  13.     }
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement