interruptThread

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

Argument Reference

threadName string

Name of the thread to interrupt. Omit to interrupt the current thread.

Compatibility

ColdFusion:

Version 2025+ Listed by getFunctionList() in ColdFusion 2025+. No official documentation exists. Signature and behavior confirmed on CF2025.

Lucee:

Version 7+ Lucee names the argument name. Passing threadName= is ignored, so Lucee interrupts the current thread instead. threadInterrupt() is an alias.

Examples
Sample code invoking the interruptThread function

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.

Fork me on GitHub