public static void main(String[] args) {
for (int i = 1; i <=10000; i++) {
new people(i+"").start();
}
}
}
class people extends Thread{
private String name;
private static int num=1;
public people(String name) {
super();
this.name = name;
}
public people() {
super();
}
@Override
public void run(){
rod();
}
public void rod() {
while (true) {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
synchronized (people.class) {
if(num<=1000){
System.out.println("di------"+this.name+"------gerenqiangdaoledi------"+num+"------zhangpiao");
people.num++;
}else {
return;
}
}
}
}