Class Runnables


  • public final class Runnables
    extends java.lang.Object
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.Runnable catchingAndLoggingThrowables​(java.lang.Runnable runnable)
      Wraps a Runnable so that throwables are caught and logged when a Runnable is run.
      • Methods inherited from class java.lang.Object

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

      • catchingAndLoggingThrowables

        public static java.lang.Runnable catchingAndLoggingThrowables​(java.lang.Runnable runnable)
        Wraps a Runnable so that throwables are caught and logged when a Runnable is run. The main usecase for this method is to be used in ScheduledExecutorService.scheduleAtFixedRate(Runnable, long, long, TimeUnit) calls to ensure that the scheduled task doesn't get cancelled as a result of an uncaught exception.
        Parameters:
        runnable - The runnable to wrap
        Returns:
        a wrapped Runnable