Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class PruebaHilos {
- public static void main(String[] args){
- new HiloRunnable(); // Se crea nuestra implementacion de Hilos con runnable
- new NuevoHilo(); // se crea la implementacion por herencia de hilos.
- try{
- for(int i=0;i<5;i++){
- System.out.println("Hilo Principal(main), dando la vuelta numero "+i);
- Thread.sleep(1000); // Aqui le pones un delay mas grande para ver la concurrencia entre hilos.
- }
- }catch(InterruptedException e) {
- System.out.println("El hilo main fue interrumpido");
- }
- System.out.println("El hilo main termino su ejecuccion"); // termina el metodo main
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement