Class AsyncSystem

java.lang.Object
io.deephaven.base.system.AsyncSystem

public class AsyncSystem extends Object
A set of conventions for logging exceptions and asynchronously exiting the JVM.
  • Constructor Details

    • AsyncSystem

      public AsyncSystem()
  • Method Details

    • uncaughtExceptionHandler

      public static Thread.UncaughtExceptionHandler uncaughtExceptionHandler(int status, PrintStream out)
      Parameters:
      status - the exit status
      Returns:
      the uncaught exception handler
    • exit

      public static void exit(String name, int status, PrintStream out)
      Starts an asynchronous call to System.exit(int). A new daemon thread will be started and it will invoke only System.exit(status). In the event that System.exit(int) throws an exception, the name of the thread and the stacktrace will be printed out.

      Note: this call will return, unlike a direct call to System.exit(int). Callers should manage this as appropriate.

      Parameters:
      name - the name to attach to the thread
      status - exit status
      out - the output print stream (on exception)
    • exitUncaught

      public static void exitUncaught(Thread thread, Throwable throwable, int status, PrintStream out)
      Prints out a message and stacktrace, and then calls exit(String, int, PrintStream). This should only be called from uncaught exception handlers.
      Parameters:
      thread - the thread
      throwable - the throwable
      status - the status
      out - the print stream
    • exitCaught

      public static void exitCaught(Thread thread, Throwable throwable, int status, PrintStream out)
      Equivalent to exitCaught(thread, throwable, status, out, null).
    • exitCaught

      public static void exitCaught(Thread thread, Throwable throwable, int status, PrintStream out, @Nullable @Nullable String message)
      Prints out a message and stacktrace, and then calls exit(String, int, PrintStream). This can be called from a thread which catches its own exceptions and wants to exit.
      Parameters:
      thread - the thread
      throwable - the throwable
      status - the status
      out - the print stream
      message - the optional additional message