Interface ServiceThreadHandling

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      boolean privilegeThread()
      Stores the current thread as privileged when the service has not been started or is currently shut down.
      void signalShutdown​(boolean emergency)
      Privileges the current thread, sets the shutdown flag and in case of emergency interrupts all active threads without the privileged ones since they are shutting down this service.
      void signalStart()
      Signals the successful start by counting down the latch and removing privileged threads.
      void unprivilegeThread()
      Revokes the privileges of the current thread that is, it may not access the service any more in case it is not started or currently shut down.
    • Method Detail

      • privilegeThread

        boolean privilegeThread()
        Stores the current thread as privileged when the service has not been started or is currently shut down. Otherwise this method just returns. If you privilege threads from a thread pool, consider unprivileging them again.

        The thread running the constructor and the thread signalling the shutdown is implicitly privileged.

        Returns:
        Whether the designated thread has really been privileged by this call. In this case the caller must unprivilege the thread. If the thread has already been privileged, false will be returned and the caller must not unprivilege the thread.
      • unprivilegeThread

        void unprivilegeThread()
        Revokes the privileges of the current thread that is, it may not access the service any more in case it is not started or currently shut down. If the current thread is not privileged, this method just returns.
        This is only useful for threads from a thread pool. Besides, all threads are implicitly unprivileged as soon as this service is started.
      • signalStart

        void signalStart()
        Signals the successful start by counting down the latch and removing privileged threads.
        This method is called implicitly by the registry. If the service is not started by the registry, this method will have to be called at the end of the start-method.
      • signalShutdown

        void signalShutdown​(boolean emergency)
        Privileges the current thread, sets the shutdown flag and in case of emergency interrupts all active threads without the privileged ones since they are shutting down this service.
        This method is called implicitly by the registry. If the service is not started by the registry, this method will have to be called at the beginning of the shutdown or emergency-shutdown-method.
        Parameters:
        emergency - Flag whether this is an emergency shutdown and the active sessions should be interrupted.