Package org.apache.jena.atlas.lib
Class ThreadLib
- java.lang.Object
-
- org.apache.jena.atlas.lib.ThreadLib
-
public class ThreadLib extends java.lang.ObjectMisc class
-
-
Constructor Summary
Constructors Constructor Description ThreadLib()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidasync(java.lang.Runnable r)Run asynchronously on another thread; the thread has started when this function returns.static <V> VcallWithAfter(java.util.function.Supplier<V> action, java.lang.Runnable after)Execute and return a value; always call the "after" runnablestatic <V> VcallWithBeforeAfter(java.util.function.Supplier<V> action, java.lang.Runnable before, java.lang.Runnable after)Execute.static <V> VcallWithLock(java.util.concurrent.locks.Lock lock, java.util.function.Supplier<V> r)Run inside a Lockstatic <T> TsyncCallThread(java.util.function.Supplier<T> r)Run synchronously but on another thread.static voidsyncOtherThread(java.lang.Runnable r)Run synchronously but on another thread.static voidwithAfter(java.lang.Runnable action, java.lang.Runnable after)Execute; always call the "after" runnablestatic voidwithBeforeAfter(java.lang.Runnable action, java.lang.Runnable before, java.lang.Runnable after)Execute.static voidwithLock(java.util.concurrent.locks.Lock lock, java.lang.Runnable r)Run inside a Lock
-
-
-
Method Detail
-
async
public static void async(java.lang.Runnable r)
Run asynchronously on another thread; the thread has started when this function returns.
-
syncOtherThread
public static void syncOtherThread(java.lang.Runnable r)
Run synchronously but on another thread.
-
syncCallThread
public static <T> T syncCallThread(java.util.function.Supplier<T> r)
Run synchronously but on another thread.
-
withBeforeAfter
public static void withBeforeAfter(java.lang.Runnable action, java.lang.Runnable before, java.lang.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(java.util.function.Supplier<V> action, java.lang.Runnable before, java.lang.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(java.lang.Runnable action, java.lang.Runnable after)Execute; always call the "after" runnable
-
callWithAfter
public static <V> V callWithAfter(java.util.function.Supplier<V> action, java.lang.Runnable after)Execute and return a value; always call the "after" runnable
-
callWithLock
public static <V> V callWithLock(java.util.concurrent.locks.Lock lock, java.util.function.Supplier<V> r)Run inside a Lock
-
withLock
public static void withLock(java.util.concurrent.locks.Lock lock, java.lang.Runnable r)Run inside a Lock
-
-