Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

java reentrantlock

import java.util.concurrent.locks.ReentrantLock;

public class test{
  public static void main(String[] args)
  {
    ReentrantLock lock = new ReentrantLock();
    
    lock.lock();
    try{
      System.out.println("Only one thread can write this at a time");
    }finally{
      lock.unlock();
    }
  }
}
 
PREVIOUS NEXT
Tagged: #java #reentrantlock
ADD COMMENT
Topic
Name
7+4 =