class ThreadText{
public static void main(String[] args) {
MyThread1 myThread11=new MyThread1();
MyThread1 myThread1111 =new MyThread1();
myThread11.setName("窗口1");
myThread1111.setName("窗口2");
myThread11.start();
myThread1111.start();
}
}
class MyThread1 extends Thread {
static Object object=new Object();
static int num=100;
ReentrantLock lock= new ReentrantLock(true);
@Override
public void run(){
while(num>=0){
lock.lock();
System.out.println(Thread.currentThread()+":"+num);
num--;
lock.unlock();
}
}
}