Class 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.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      abstract T create()
      Override to create the actual object
      T get()
      Get the value or wait until it is created.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ConcurrentInitialize

        public ConcurrentInitialize()
    • 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