public class CancellationUtil extends Object
Constructor and Description |
---|
CancellationUtil() |
Modifier and Type | Method and Description |
---|---|
static <T> T |
monitorAsync(Callable<T> process,
Runnable killer,
CancelCheck cancelCheck)
Starts a process in a separate thread and lets it run till canceled.
|
static void |
monitorAsync(Runnable process,
Runnable killer,
CancelCheck cancelCheck) |
static <T> T |
monitorSync(Callable<T> process,
Runnable killer,
CancelCheck cancelCheck)
Starts a process and monitor it from a separate thread.
|
static void |
monitorSync(Runnable process,
Runnable killer,
CancelCheck cancelCheck) |
public static void monitorAsync(Runnable process, Runnable killer, CancelCheck cancelCheck)
public static <T> T monitorAsync(Callable<T> process, Runnable killer, CancelCheck cancelCheck)
monitorSync(Callable, Runnable, CancelCheck)
method.
If the process is not cancelled, the method returns the value returned by the process function. If the process throws, its exception is
propagated.T
- the type of the process return valueprocess
- the process functionkiller
- the kill function, it will be called only oncecancelCheck
- the cancel check to receive external cancellation signalspublic static void monitorSync(Runnable process, Runnable killer, CancelCheck cancelCheck)
public static <T> T monitorSync(Callable<T> process, Runnable killer, CancelCheck cancelCheck)
monitorAsync(Callable, Runnable, CancelCheck)
method.
If the process is not cancelled, the method returns the value returned by the process function. If the process throws, its exception is
propagated.T
- the type of the process return valueprocess
- the process functionkiller
- the kill function, it will be called only oncecancelCheck
- the cancel check to receive external cancellation signalsCopyright © 2010-2016 Stardog Union. All Rights Reserved.