The process.join(NUM_SECONDS)
does not fit, because the normal for
loop
to join all the processes waits NUM_SECONDS
for each process before joining it.
We want a global amount of NUM_SECONDS
to be timed out on to kill (terminate
)
all the outstanding processes that are still alive after NUM_SECONDS
elapsed
(i.e. not yet been join
ed already).
The following code snippet has been heavily inspired by: