?? animal_yingjj.java
字號(hào):
package com.jk.thread;
public class Animal_yingjj implements Runnable{
private String name;
private int s;
private int v;
public Animal_yingjj(String name){
this.name=name;
}
public void run(){
while(true){
try {
Thread.currentThread().sleep(50);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
v=(int)(Math.random()*10);
s+=v;
System.out.println("Name is "+name+" s is "+s+" v is "+v);
if(s>=1000){
System.out.println("Winner is "+name);
System.exit(1);
}
}
}
public static void main(String[] args){
Animal_yingjj pig=new Animal_yingjj("pig");
Animal_yingjj dog=new Animal_yingjj("dog");
new Thread(pig).start();
new Thread(dog).start();
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -