In class Semaphore tryAcquire() and tryAcquire(n) each call Semaphore.Sync.nonfairTryAcquireShared(1) which appears to busy wait until enough permits are available, returning immediately if there are enough available. Therefore barging is possible. tryAcquire(t, unit) and tryAcquire(n, t, unit) each call java.util.concurrent.locks.AbstractQueuedSynchronizer .tryAcquireSharedNanos(1, unit.toNanos(t)) which calls AbstractQueuedSynchronizer.doAcquireShared which clearly queues the thread if not enough permits are available. Therefore no barging is possible, even if the timeout is 0.
Missing content
Missing content
Sorry, I didn't do the graphics...
Missing content
Missing content
Missing content