hilos1.java

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

JAVA
28
字号

public class Hilos1 implements Runnable {
	String name;
	public  Hilos1(String str) 
    {
     name = str;
    }
    public void run() 
    {
        for (int i = 0; i < 20; i++){
            System.out.println(i + " Hilos 2" + name);
            try 
            {
               Thread.sleep((int)(Math.random() * 1000));
             
            } 
            catch (InterruptedException e) 
            {
            }
           
        }
        System.out.println("HECHO! " + name);
        
              
    }
    
}

⌨️ 快捷键说明

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