jfcmacro

CrearThread.java

Mar 26th, 2019
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.44 KB | None | 0 0
  1. class CrearThread extends Thread {
  2.  
  3.     public CrearThread() {
  4.     super();
  5.     }
  6.    
  7.     public void run() {
  8.     for (int i = 0;  i < 10; ++i) {
  9.         System.out.println("Hilo: " + Thread.currentThread());
  10.     }
  11.     }
  12.  
  13.     public static void main(String args[]) {
  14.     CrearThread t1 = new CrearThread();
  15.     CrearThread t2 = new CrearThread();
  16.  
  17.     t1.start();
  18.     t2.start();
  19.     try {
  20.         t1.join();
  21.         t2.join();
  22.     }
  23.     catch (InterruptedException ie) { }
  24.     }
  25.    
  26. }
Advertisement
Add Comment
Please, Sign In to add comment