AbstractQueueSynchronization
維護了一個volatile int state代表共享資源和一個FIFO線程等待隊列
AQS定義了兩種資源共享方式:獨佔(Exclusive)和共享(share)
isHeldExclusively方法:該線程是否在獨佔資源
tryAcquire/tryRelease:獨佔的方式嘗試去獲取和釋放資源。
tryAcquireShared/tryReleaseShared:共享的方式嘗試去獲取和釋放資源。
AbstractQueueSynchronization
維護了一個volatile int state代表共享資源和一個FIFO線程等待隊列
AQS定義了兩種資源共享方式:獨佔(Exclusive)和共享(share)
isHeldExclusively方法:該線程是否在獨佔資源
tryAcquire/tryRelease:獨佔的方式嘗試去獲取和釋放資源。
tryAcquireShared/tryReleaseShared:共享的方式嘗試去獲取和釋放資源。