Interrupts a running thread created with cfthread or threadNew. A thread that is sleeping or waiting gets an exception; otherwise its interrupted flag is set, which it can check with threadInterrupted(). With no argument, interrupts the current thread, which must itself be a ColdFusion thread. Unlike threadTerminate(), the thread can handle the interrupt and stop cleanly.
interruptThread([threadName])
→ returns void
name. Passing threadName= is ignored, so Lucee interrupts the current thread instead. threadInterrupt() is an alias.
The thread's sleep() throws an exception, which it catches.
thread name="worker" {
try {
sleep(5000);
} catch (any e) {
thread.message = e.message;
}
}
sleep(200);
interruptThread("worker");
threadJoin("worker");
writeOutput(cfthread.worker.message);
Expected Result: Thread interrupted by another thread.
Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.