public final class InitializeInThread
extends java.lang.Object
How to use it:
InitializeInThread.Initializable interface defined
 in this class.waitInitialization() so the thread going to execute that code
 waits until initialization is complete or raises errors
 private static final InitializeInThread intializationStatus = new InitializeInThread(new Initializable() {             
   public void initialize() {
     prepareProcessorInASeparateThread();
   }
 });
 static {
   intializationStatus.start();
 }
 
 
 There are examples of uses of this class in all the following classes:
 RSRemoteCatalogResolver, TaxonomyPackageUriResolver, ZipCascadeURIResolver
 
 This is how this process works
start() will check the status is INITIALIZABLE and
     will start initialization. If several threads call start simultaneously
     only one starts the initialization thread and the others will raise
     an exception| Modifier and Type | Class and Description | 
|---|---|
| static interface  | InitializeInThread.Initializablethis is the interface that must be implemented by a class
 that will contain a callback method called  InitializeInThread.Initializable.initialize(). | 
| static class  | InitializeInThread.InitializationResultThe Enum InitializationResult:
 
  InitializeInThread.InitializationResult.PENDINGInitializeInThread.InitializationResult.INITIALIZABLEInitializeInThread.InitializationResult.RUNNINGInitializeInThread.InitializationResult.ERRORInitializeInThread.InitializationResult.INITIALIZEDInitializeInThread.InitializationResult.CANCELLED. | 
| Constructor and Description | 
|---|
| InitializeInThread(InitializeInThread.Initializable task)creates an instance of the Initialize thread and calls initialize
 on the parameter. | 
| Modifier and Type | Method and Description | 
|---|---|
| void | cancel()Cancel Sets the status to CANCELLED and error is set to null
  If the status is RUNNING, then after the finalization of the
 initialization thread, the status is not changed to 
 ERROR or INITIALIZED but remains in CANCELLED status. | 
| java.lang.Throwable | getError()If the status is ERROR, a call to this method returns the error thar was
 generated during the initialization phase. | 
| InitializeInThread.InitializationResult | getStatus()Access to the initialization status. | 
| void | start()Starts initialization and returns immediately. | 
| void | waitInitialization()If the class is initializing a call to this method by another
 thread will wait until the initialization process ends. | 
public InitializeInThread(InitializeInThread.Initializable task)
task - the taskjava.lang.IllegalStateException - if the task arguments was already usedpublic void start()
The initialization run in a separate thread
java.lang.IllegalStateException - if the initialization cannot be called
         most likely because it is already running or was already
         executedpublic void cancel()
If the status is RUNNING, then after the finalization of the initialization thread, the status is not changed to ERROR or INITIALIZED but remains in CANCELLED status.
If the status is in any other value, this call sets the status to CANCELLED and nothing else happens.
public void waitInitialization()
                        throws java.lang.InterruptedException
Errors generated during the initialization phase are captured and raised at this time as instances of InterruptedException with a suppressed exception that contains the original error
 If the initialization was cancelled, this method raises an
 InterruptedException as well but without additional information.
 A call to getStatus() can be used to distinguish a 
 cancellation from an error
java.lang.InterruptedException - the interrupted exceptionpublic java.lang.Throwable getError()
public InitializeInThread.InitializationResult getStatus()
InitializeInThread.InitializationResult enumerationCopyright 2006-2015 Reporting Standard S.L., C/ Torrecilla del Puerto 1, 28043, Madrid, Espaņa