public class Oups {
     private int value;
     private final Object readLock = new Object();
     private final Object writeLock = new Object();

     public void setValue(int value) {
       synchronized(readLock) {
         synchronized(writeLock) {
           this.value = value;
         }
       }
     }

     public int getValue() {
       synchronized(readLock) {
         return value;
       }
     }

     public void performs() throws InterruptedException {
       Thread t = new Thread(() -> setValue(12));
       synchronized(writeLock) {
         t.start();
         Thread.sleep(1_000);
         System.out.println(getValue());
       }
     }

     public static void main(String[] args) throws InterruptedException {
       Oups oups = new Oups();
       oups.performs();
     }
   }