class class12{
int i=80;
class test_do implements Runnable{
private String name;
public test_do(String name)
{
this.name=name;
}
@Override
public void run() {
// TODO Auto-generated method stub
while(i>0)
{
if(i>0)
{
System.out.println("编号:"+(i--)+"被分到了"+name);
}
}
}
}
public test_do getInstance(String name)
{
return new test_do(name);
}
public static void main(String[] args){
class12 c12 = new class12();
test_do td1 = c12.getInstance("第一组");
test_do td2 = c12.getInstance("第二组");
test_do td3 = c12.getInstance("第三组");
test_do td4 = c12.getInstance("第四组");
new Thread(td1).start();
new Thread(td2).start();
new Thread(td3).start();
new Thread(td4).start();
}
} |