Whatever message this page gives is out now! Go check it out!

InterruptThread

Last update:
May 18, 2026

Description

Interrupts given thread. When interrupt is called on a thread it sets interrupt status flag on CFThread. If a thread is blocked in an invocation of the ThreadJoin or sleep method, then its interrupt status will be cleared, and it will receive an InterruptedException. Interrupting a thread that is not alive need not have any effect.

Returns

None

Syntax

interruptThread()

interruptThread(threadName)

Parameters

  • threadName: (Optional) Name of the thread to interrupt. If you do not provide the thread name, the current thread will be interrupted.

History

  • ColdFusion (2025 release): Added the function.

Example

code
<cfscript>
        testThreadName = "interrupt-self"

        thread action="run" name="#testThreadName#" {
            variables.message = "before interrupt...<br>"
            variables.message &= "isInterrupted:" & isThreadInterrupted(testThreadName) & "<br>"
            interruptThread();
            variables.message &= "after interrupt...<br>"
            variables.message &= "isInterrupted:" & isThreadInterrupted(testThreadName) & "<br>"
            
        } 
        thread action="join" name="#testThreadName#"{}
        writeOutput(variables.message)
        writeOutput("isInterrupted:" & isThreadInterrupted(testThreadName) & "<br>")
</cfscript>

Output

before interrupt...

isInterrupted:NO

after interrupt...

isInterrupted:YES

isInterrupted:YES

Share this page

Was this page helpful?
We're glad. Tell us how this page helped.
We're sorry. Can you tell us what didn't work for you?
Thank you for your feedback. Your response will help improve this page.

On this page