package com.wuhongyu.test1.test;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
public class Thhhhh implements Runnable{
private static int a = 100;
Lock lock = new ReentrantLock();
@Override
public void run() {
while (true) {
try {
lock.lock();
if (a > 0) {
System.out.println(Thread.currentThread().getName()+":"+a);
a--;
}
}finally {
lock.unlock();
}
}
}
}
买票
最新推荐文章于 2022-10-08 21:19:00 发布