Class StartupCountdown
- java.lang.Object
-
- org.jboss.as.ee.component.deployers.StartupCountdown
-
public final class StartupCountdown extends Object
Countdown tracker with capabilities similar to SE CountDownLatch, but allowing threads to mark and unmark themselves as privileged. Privileged threads, when entering await method, will immediately proceed without checking latch's state. This reentrant behaviour allows to work around situations where there is a possibility of a deadlock.- Author:
- Fedor Gavrilov
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
StartupCountdown.Frame
-
Constructor Summary
Constructors Constructor Description StartupCountdown(int count)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addCallback(Runnable callback)
Executes a lightweight action when the countdown reaches 0.void
await()
void
countDown()
void
countUp(int count)
static StartupCountdown.Frame
current()
StartupCountdown.Frame
enter()
boolean
isPrivileged()
static void
restore(StartupCountdown.Frame frame)
-
-
-
Method Detail
-
countDown
public void countDown()
-
countUp
public void countUp(int count)
-
await
public void await() throws InterruptedException
- Throws:
InterruptedException
-
addCallback
public void addCallback(Runnable callback)
Executes a lightweight action when the countdown reaches 0. If StartupCountdown is not at zero when the method is called, passed callback will be executed by the last thread to call countDown. If StartupCountdown is at zero already, passed callback will be executed immediately by the caller thread.- Parameters:
callback
- to execute. Should not be null.
-
isPrivileged
public boolean isPrivileged()
-
enter
public StartupCountdown.Frame enter()
-
current
public static StartupCountdown.Frame current()
-
restore
public static void restore(StartupCountdown.Frame frame)
-
-