Home › Forums › Development › how to keep track of ThreadUtil.bgRun thread and stop them eventually? › Reply To: how to keep track of ThreadUtil.bgRun thread and stop them eventually?

#66363

Hi Fred,

ThreadUtil.bgRun(..) doesn’t let you to interrupt thread and in fact you cannot really interrupt a thread in java. Instead you have to take care of that yourself by providing a flag in your executor code to interrupt the process :

// need to interrupt process ? –> return now
if (isInterrupted) return;

Note that Thread object does have an interrupt properties you can check for, but you cannot directly change it for the BG runner of Icy (you need to do your own thread in this case). But of course you can always have your own ‘interrupt’ flag in your Runner class 🙂

Hope that help.

– Stephane