Code example for Queue

Methods: peek

0
      if(wasInterrupted) current.interrupt();
    } 
     
    public void unlock() { 
      locked.set(false);
      LockSupport.unpark(waiters.peek());
    } 
  } 
   
  private static final FIFOMutex mut = new FIFOMutex();
   
  static class PrintThread extends Thread {
    private String msg;
    public PrintThread(String msg) {
      this.msg = msg;
    } 
    public void run() { 
      mut.lock();
      System.out.println(msg);
      mut.unlock();
    }