hilos2.java

来自「example in C using threads」· Java 代码 · 共 31 行

JAVA
31
字号

public class Hilos2 implements Runnable {
	   String name;
	   public Hilos2(String str) 
	    {
	       name = str;
	    }
	   

	    public void run() 
	    {
	        for (int i = 0; i < 10; i++){
	            System.out.println("Hilo" + name);
	            try 
	            {
	               Thread.sleep((int)(Math.random() * 1000));
	           
	            } 
	            catch (InterruptedException e) 
	            {
	            }
	           
	        }
	        System.out.println("DONE! " + name);
	             
	    }
}



⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?