Class NonReentrantLock.Sync

  • All Implemented Interfaces:
    java.io.Serializable, java.util.concurrent.locks.Lock
    Enclosing class:
    NonReentrantLock

    static final class NonReentrantLock.Sync
    extends java.util.concurrent.locks.AbstractQueuedSynchronizer
    implements java.util.concurrent.locks.Lock, java.io.Serializable
    A non-fair lock using AQS state to represent if the lock is held.
    • Nested Class Summary

      • Nested classes/interfaces inherited from class java.util.concurrent.locks.AbstractQueuedSynchronizer

        java.util.concurrent.locks.AbstractQueuedSynchronizer.ConditionObject
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) static int LOCKED  
      (package private) static long serialVersionUID  
      (package private) static int UNLOCKED  
    • Constructor Summary

      Constructors 
      Constructor Description
      Sync()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Thread getOwner()  
      protected boolean isHeldExclusively()  
      boolean isLocked()  
      void lock()  
      void lockInterruptibly()  
      java.util.concurrent.locks.Condition newCondition()  
      private void readObject​(java.io.ObjectInputStream s)  
      protected boolean tryAcquire​(int acquires)  
      boolean tryLock()  
      boolean tryLock​(long time, java.util.concurrent.TimeUnit unit)  
      protected boolean tryRelease​(int releases)  
      void unlock()  
      • Methods inherited from class java.util.concurrent.locks.AbstractQueuedSynchronizer

        acquire, acquireInterruptibly, acquireShared, acquireSharedInterruptibly, compareAndSetState, getExclusiveQueuedThreads, getFirstQueuedThread, getQueuedThreads, getQueueLength, getSharedQueuedThreads, getState, getWaitingThreads, getWaitQueueLength, hasContended, hasQueuedPredecessors, hasQueuedThreads, hasWaiters, isQueued, owns, release, releaseShared, setState, toString, tryAcquireNanos, tryAcquireShared, tryAcquireSharedNanos, tryReleaseShared
      • Methods inherited from class java.util.concurrent.locks.AbstractOwnableSynchronizer

        getExclusiveOwnerThread, setExclusiveOwnerThread
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • Sync

        Sync()
    • Method Detail

      • lock

        public void lock()
        Specified by:
        lock in interface java.util.concurrent.locks.Lock
      • lockInterruptibly

        public void lockInterruptibly()
                               throws java.lang.InterruptedException
        Specified by:
        lockInterruptibly in interface java.util.concurrent.locks.Lock
        Throws:
        java.lang.InterruptedException
      • tryLock

        public boolean tryLock()
        Specified by:
        tryLock in interface java.util.concurrent.locks.Lock
      • tryLock

        public boolean tryLock​(long time,
                               java.util.concurrent.TimeUnit unit)
                        throws java.lang.InterruptedException
        Specified by:
        tryLock in interface java.util.concurrent.locks.Lock
        Throws:
        java.lang.InterruptedException
      • unlock

        public void unlock()
        Specified by:
        unlock in interface java.util.concurrent.locks.Lock
      • newCondition

        public java.util.concurrent.locks.Condition newCondition()
        Specified by:
        newCondition in interface java.util.concurrent.locks.Lock
      • tryAcquire

        protected boolean tryAcquire​(int acquires)
        Overrides:
        tryAcquire in class java.util.concurrent.locks.AbstractQueuedSynchronizer
      • tryRelease

        protected boolean tryRelease​(int releases)
        Overrides:
        tryRelease in class java.util.concurrent.locks.AbstractQueuedSynchronizer
      • isHeldExclusively

        protected boolean isHeldExclusively()
        Overrides:
        isHeldExclusively in class java.util.concurrent.locks.AbstractQueuedSynchronizer
      • isLocked

        public boolean isLocked()
      • getOwner

        public java.lang.Thread getOwner()
      • readObject

        private void readObject​(java.io.ObjectInputStream s)
                         throws java.io.IOException,
                                java.lang.ClassNotFoundException
        Throws:
        java.io.IOException
        java.lang.ClassNotFoundException