Package aQute.lib.concurrentinit
Class ConcurrentInitialize<T>
- java.lang.Object
-
- aQute.lib.concurrentinit.ConcurrentInitialize<T>
-
- Type Parameters:
T
-
public abstract class ConcurrentInitialize<T> extends java.lang.Object
Helper class to handle concurrent system where you need to initialize a value. The first one should create the value but the others should block until the value has been created. Since we do not want to hold a lock during the creation this is kind of tricky. This class uses a single monitorlock
that oeprates a state machine.
-
-
Constructor Summary
Constructors Constructor Description ConcurrentInitialize()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract T
create()
Override to create the actual objectT
get()
Get the value or wait until it is created.
-
-
-
Method Detail
-
get
public T get() throws java.lang.Exception
Get the value or wait until it is created.- Throws:
java.lang.Exception
-
create
public abstract T create() throws java.lang.Exception
Override to create the actual object- Returns:
- the actual object, could be null
- Throws:
java.lang.Exception
- if the creation failed this is the exception that was thrown
-
-