Module ojalgo

Class ProcessAwareThread

java.lang.Object
java.lang.Thread
org.ojalgo.concurrent.ProcessAwareThread
All Implemented Interfaces:
Runnable

final class ProcessAwareThread extends Thread
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