Class ShutdownHooks

java.lang.Object
dev.getelements.elements.sdk.util.ShutdownHooks

public class ShutdownHooks extends Object
A simple way to manage shutdown hooks. Each instance of ShutdownHooks submits a thread to the system runtime which will be executed upon shutdown of the virtual machine. Each action in this instance is executed serially in the order in which it was queued to this instance of ShutdownHooks. It is safe to queue multiple ShutdownHooks.Actions from multiple threads. This type internally uses a simple lockless linked-list to queue all actions. Once queued, the action may not be removed from the queue so the author of the action must ensure that there are no side effects if the associated action is no longer needed. Each action may throw an exception, in which case it will be logged to a logger specified by the class that owns the shutdown hooks. Created by patricktwohig on 8/23/17.
  • Constructor Details

    • ShutdownHooks

      public ShutdownHooks(Class<?> aClass)
      Uses the supplied Class<?>'s logger to log the shutdown hooks action.
      Parameters:
      aClass - the class which owns the ShutdownHooks
    • ShutdownHooks

      public ShutdownHooks(org.slf4j.Logger logger)
      Allows for the owner of this ShutdownHooks instance to specify a custom Logger which will be used to log the information of the associated actions.
      Parameters:
      logger - the actions
  • Method Details