📜  java reentrantlock - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:28.401000             🧑  作者: Mango

代码示例2
import java.util.concurrent.locks.ReentrantLock;

public class test{
  public static void main(String[] args)
  {
    ReentrantLock r1 = new ReentrantLock();
    
    r1.lock();
    System.out.println("Only one thread can write this at a time");
    r1.unlock();
  }
}