50,709
社区成员
发帖
与我相关
我的任务
分享
class ThreadTest2
{
public static void main(String[] args)
{
new Thread(new Thread1("Thread1")).start();
new Thread(new Thread1("Thread2")).start();
}
}
class Thread1 implements Runnable
{
private String name;
private static int tit = 100;
public Thread1(String name) {
this.name = name;
}
public String getName(){
return this.name;
}
public void run() {
while(tit>0) {
synchronized(new Object()) {
System.out.println(this.getName()+"___"+tit--);
}
}
}
}