Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

ReentrantLock java

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();
  }
}
 
PREVIOUS NEXT
Tagged: #ReentrantLock #java
ADD COMMENT
Topic
Name
8+9 =