Class ProcessAwareThread
java.lang.Object
java.lang.Thread
org.ojalgo.concurrent.ProcessAwareThread
- All Implemented Interfaces:
Runnable
A daemon thread that can be bound to an external
Process. When this thread is interrupted, it will
attempt to forcibly terminate the bound process before delegating to Thread.interrupt().
Typical usage:
Thread t = DaemonPoolExecutor.newProcessAwareThreadFactory("ojAlgo-proc").newThread(() -> {
Process p = new ProcessBuilder("sleep", "10").start();
if (Thread.currentThread() instanceof ProcessAwareThread pat) pat.setProcess(p);
p.waitFor();
});
t.start();
// later...
t.interrupt(); // will destroy the process
-
Nested Class Summary
Nested classes/interfaces inherited from class Thread
Thread.Builder, Thread.State, Thread.UncaughtExceptionHandler -
Field Summary
FieldsFields inherited from class Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class Thread
activeCount, checkAccess, clone, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupted, isAlive, isDaemon, isInterrupted, isVirtual, join, join, join, join, ofPlatform, ofVirtual, onSpinWait, run, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, sleep, start, startVirtualThread, stop, threadId, toString, yield
-
Field Details
-
myReference
-
-
Constructor Details
-
ProcessAwareThread
ProcessAwareThread(ThreadGroup group, Runnable target, String name)
-
-
Method Details
-
interrupt
-
setProcess
-