Class ThreadLib

java.lang.Object
org.apache.jena.atlas.lib.ThreadLib

public class ThreadLib extends Object
Misc class
  • Constructor Details

    • ThreadLib

      public ThreadLib()
  • Method Details

    • getExecutionService

      public static ExecutorService getExecutionService()
    • async

      public static void async(Runnable r)
      Run asynchronously on another thread; the thread has started when this function returns.
    • syncOtherThread

      public static void syncOtherThread(Runnable r)
      Run synchronously but on another thread.
    • syncCallThread

      public static <T> T syncCallThread(Supplier<T> r)
      Run synchronously but on another thread.
    • withBeforeAfter

      public static void withBeforeAfter(Runnable action, Runnable before, Runnable after)
      Execute. Perform the "before" action, then main action. Always call the "after" runnable if the "before" succeeded. Be careful about argument order.
      Parameters:
      action -
      before -
      after -
    • callWithBeforeAfter

      public static <V> V callWithBeforeAfter(Supplier<V> action, Runnable before, Runnable after)
      Execute. Perform the "before" action, then main action. Always call the "after" runnable if the "before" succeeded. Be careful about argument order.
      Parameters:
      action -
      before -
      after -
    • withAfter

      public static void withAfter(Runnable action, Runnable after)
      Execute; always call the "after" runnable
    • callWithAfter

      public static <V> V callWithAfter(Supplier<V> action, Runnable after)
      Execute and return a value; always call the "after" runnable
    • callWithLock

      public static <V> V callWithLock(Lock lock, Supplier<V> r)
      Run inside a Lock
    • withLock

      public static void withLock(Lock lock, Runnable r)
      Run inside a Lock