1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
import java.util.concurrent.TimeUnit; public class HelloRunnable implements Runnable { public void run() { System.out.println("Ejecutando hilo"); System.out.println(Thread.currentThread().getName()); } public static void main(String args[]) { System.out.println(Thread.currentThread().getName()); int i=0; while(i<100) { (new Thread(new HelloRunnable())).start(); try { TimeUnit.SECONDS.sleep(10); } catch (InterruptedException e) { e.printStackTrace(); } i++; } } } |