Advertisement
everblut

Prueba Hilos

Sep 20th, 2011
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.62 KB | None | 0 0
  1. public class PruebaHilos {
  2.  
  3.     public static void main(String[] args){
  4.    
  5.     new HiloRunnable(); // Se crea nuestra implementacion de Hilos con runnable
  6.     new NuevoHilo(); // se crea la implementacion por herencia de hilos.
  7.  
  8.     try{
  9.         for(int i=0;i<5;i++){
  10.         System.out.println("Hilo Principal(main), dando la vuelta numero "+i);
  11.         Thread.sleep(1000); // Aqui le pones un delay mas grande para ver la concurrencia entre hilos.
  12.         }
  13.     }catch(InterruptedException e) {
  14.         System.out.println("El hilo main fue interrumpido");
  15.     }
  16.     System.out.println("El hilo main termino su ejecuccion"); // termina el metodo main
  17.     }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement