Package com.atlassian.jira.concurrent
Interface Barrier
@Internal
public interface Barrier
The barrier allows us to hold up an operation for a short while. This class is not API and should only be used
for testing.
Barriers must be lowered in a finally block so as to avoid blocking operations forever.
- Since:
- v5.2
-
Method Summary
Modifier and TypeMethodDescriptionvoidawait()Blocks the calling thread until the barrier is lowered or the calling thread is interrupted.voidlower()Lowers the barrier.voidLower the barrier to allow waiting threads through, then immediately raise it again.name()Returns this barrier's name.voidraise()Raises the barrier.
-
Method Details
-
name
String name()Returns this barrier's name.- Returns:
- a String containing the barrier's name
-
await
void await()Blocks the calling thread until the barrier is lowered or the calling thread is interrupted. Callers may useThread.isInterrupted()to check if the thread has been interrupted. -
raise
void raise()Raises the barrier. Threads that callawait()when the barrier is raised will block indefinitely until the barrier is lowered again. -
lower
void lower()Lowers the barrier. Any threads that are blocked onawait()will no longer be blocked. -
lowerThenRaise
void lowerThenRaise()Lower the barrier to allow waiting threads through, then immediately raise it again. Waiting threads are only allowed through once. This is useful for stepping through loops containing a barrier.
-