do some other things. Initialization runs in a parallel thread ... // Wait for the end of initialization and access the result object Object result = initializer.get();
After the construction of a {@code BackgroundInitializer} object its{@link #start()} method has to be called. This starts the backgroundprocessing. The application can now continue to do other things. When it needs access to the object produced by the {@code BackgroundInitializer} itcalls its {@link #get()} method. If initialization is already complete,{@link #get()} returns the result object immediately. Otherwise it blocksuntil the result object is fully constructed.
{@code BackgroundInitializer} is a thin wrapper around a {@code Future}object and uses an {@code ExecutorService} for running the backgroundinitialization task. It is possible to pass in an {@code ExecutorService} atconstruction time or set one using {@code setExternalExecutor()} before{@code start()} was called. Then this object is used to spawn the backgroundtask. If no {@code ExecutorService} has been provided, {@code BackgroundInitializer} creates a temporary {@code ExecutorService} anddestroys it when initialization is complete.
The methods provided by {@code BackgroundInitializer} provide for minimalinteraction with the wrapped {@code Future} object. It is also possible toobtain the {@code Future} object directly. Then the enhanced functionalityoffered by {@code Future} can be used, e.g. to check whether the backgroundoperation is complete or to cancel the operation.
@version $Id: BackgroundInitializer.java 929189 2010-03-30 16:49:22Z oheger $
@param < T> the type of the object managed by this initializer class