| Modifier and Type | Field and Description |
|---|---|
| private String | |
| private final long | |
| private int | |
| private Object | |
| private Semaphore | |
| private ThreadLocal | |
| private final long |
| Access | Constructor and Description |
|---|---|
| public | ConcurrencySemaphore(ThreadLocal<Boolean>
Thread local variable that the code to acquire a semaphore can check to make sure it does not try to acquire
twice the same semaphore (e.g. in case the object building algorithm is recursive). threadLocalVarControlIfCurrentThreadHasAcquiredSemaphore, int Max number of threads to acquire semaphore. noOfThreadsAllowedToExecuteInParallel, Semaphore Semaphore used to control. semaphoreOfThreadsAllowedToExecuteInParallel, Object Reference to outer object where is this semaphore used. outerObject, String Log message key from logMessageKey)org.Constructor to create |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | Returns: FALSE is returned if we do not want to be using the semaphore. FALSE is also returned if the current thread has acquire the semaphore in an upper level recursive stack call. TRUE is returned if and only using the semaphore is desired and we succeed acquiring the semaphore.TRUE to use semaphore, FALSE don't use it. useSemaphore)Do nothing if the semaphore has already been acquired by this thread in a higher recursive call or if the configuration to acquire the slow down semaphore is not active. |
| public void | releaseSemaphoreAllowOtherThreadsToStartDoingObjectBuilding(boolean
flag that tells us if the current thread had successfully acquired semaphore if the flag is true then
the semaphore will be released and given resources again. semaphoreWasAcquired)If the call to
|
| logMessageKey | back to summary |
|---|---|
| private String logMessageKey | |
| MAX_TIME_PERMIT | back to summary |
|---|---|
| private final long MAX_TIME_PERMIT | |
| noOfThreads | back to summary |
|---|---|
| private int noOfThreads | |
| outerObject | back to summary |
|---|---|
| private Object outerObject | |
| semaphore | back to summary |
|---|---|
| private Semaphore semaphore | |
| threadLocal | back to summary |
|---|---|
| private ThreadLocal<Boolean> threadLocal | |
| TIMEOUT_BETWEEN_LOG_MESSAGES | back to summary |
|---|---|
| private final long TIMEOUT_BETWEEN_LOG_MESSAGES | |
| ConcurrencySemaphore | back to summary |
|---|---|
| public ConcurrencySemaphore(ThreadLocal<Boolean> threadLocalVarControlIfCurrentThreadHasAcquiredSemaphore, int noOfThreadsAllowedToExecuteInParallel, Semaphore semaphoreOfThreadsAllowedToExecuteInParallel, Object outerObject, String logMessageKey) Constructor to create
| |
| acquireSemaphoreIfAppropriate | back to summary |
|---|---|
| public boolean acquireSemaphoreIfAppropriate(boolean useSemaphore) Do nothing if the semaphore has already been acquired by this thread in a higher recursive call or if the configuration to acquire the slow down semaphore is not active. Otherwise, try to acquire the semaphore
| |
| releaseSemaphoreAllowOtherThreadsToStartDoingObjectBuilding | back to summary |
|---|---|
| public void releaseSemaphoreAllowOtherThreadsToStartDoingObjectBuilding(boolean semaphoreWasAcquired) If the call to
| |