public class AccessSemaphore extends Object
A typical use-case for exclusive/shared access might be single writer/multiple readers
Since this access mechanism builds on a simple semaphore, it is straightforward to bound the number of shares permitted. By default this is set to MAXINT, but it need not be, and a constructor is provided to define this limit.
It is NOT re-entrant.
Modifier and Type | Class and Description |
---|---|
class |
AccessSemaphore.Access |
static class |
AccessSemaphore.AccessSemaphoreNotReentrantException |
class |
AccessSemaphore.ExclusiveAccess |
class |
AccessSemaphore.SharedAccess |
Constructor and Description |
---|
AccessSemaphore() |
AccessSemaphore(int maxShares) |
Modifier and Type | Method and Description |
---|---|
AccessSemaphore.Access |
acquireExclusive() |
AccessSemaphore.Access |
acquireShared() |
AccessSemaphore.Access |
tryAcquireExclusive(long timeout,
TimeUnit unit) |
AccessSemaphore.Access |
tryAcquireShared(long timeout,
TimeUnit unit) |
public AccessSemaphore()
public AccessSemaphore(int maxShares)
public final AccessSemaphore.Access acquireExclusive() throws InterruptedException
InterruptedException
public final AccessSemaphore.Access tryAcquireExclusive(long timeout, TimeUnit unit) throws InterruptedException
InterruptedException
public final AccessSemaphore.Access acquireShared() throws InterruptedException
InterruptedException
public final AccessSemaphore.Access tryAcquireShared(long timeout, TimeUnit unit) throws InterruptedException
InterruptedException
Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.