- java.lang.Object
-
- java.lang.Thread
-
- org.ojalgo.concurrent.ProcessAwareThread
-
- All Implemented Interfaces:
java.lang.Runnable
final class ProcessAwareThread extends java.lang.ThreadA daemon thread that can be bound to an externalProcess. When this thread is interrupted, it will attempt to forcibly terminate the bound process before delegating toThread.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
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.concurrent.atomic.AtomicReference<java.lang.Process>myReference
-
Constructor Summary
Constructors Constructor Description ProcessAwareThread(java.lang.ThreadGroup group, java.lang.Runnable target, java.lang.String name)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidinterrupt()(package private) voidsetProcess(java.lang.Process process)-
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, run, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
-
-