信号(Semaphore)源码
成员:sync方法:acquire acquire(int) acquireUnInterruptibly acquireUnInterruptily(int) tryAcquire tryAcquire(int) tryAcquire(long, TimeUnit) ?tryAcquire(int, long, TimeUnit)release ?release(int)?availablePermits ?drainPermits ?isFair ?hasQueueThreads ?getQueueLength内部类:Sync ?NonFairSync ?FairSync两个子Sync都覆盖了tryAcquireShared非公平的是拿当前状态和acquires相减然后compareAndSetState公平的比非公平的多一个步骤,就是在之前通过getFirstQueuedThread获取线程和当前线程相比,FIFO公平?tryAcquireSharedtryAcquire