Loom structured concurrency can help us with this. The blocking calls can be handled with lightweight Loom threads. And the structured concurrency helps us with error ...
import java.io.IOException; public class ProcessDemo { public static void main(String[] args) throws IOException { Process p = new ProcessBuilder("notepad.exe").start ...