ThreadJoin

Description

Makes the current thread wait until the thread or threads specified complete processing.

Function syntax

ThreadJoin([threadName], [timeout])

History

ColdFusion 9: Added this function.

Parameters

Parameter

Description

threadName

The name of the thread or threads to join to the current thread. To specify multiple threads, use a comma-separated list.

timeout

The number of milliseconds for which to suspend thread processing.

Usage

Makes the current thread wait until the thread or threads specified in the threadNameparameter complete processing, or until the period specified in the timeoutparameter passes, before continuing processing.

  • ThreadJoin(): Current thread waits for all ColdFusion threads to complete processing.

  • ThreadJoin(threadName): Makes current thread wait for the specified thread to finish execution.

  • ThreadJoin(threadName, timeout): Makes the current thread wait until execution timeout for one or many threads specified by threadName. If you do not specify a timeout and the thread you are joining to does not finish, the current thread also cannot finish processing.

Example

<cfscript> 
thread name="t1" 
    { 
        sleep(5000); 
    } 
thread name="t2" 
    { 
        threadjoin("t1",1000); 
    } 
threadjoin("t2"); 
</cfscript> 
<cfoutput>Status of the thread T1 = #t1.Status#<br></cfoutput> 
<cfoutput>Status of the thread T2 = #t2.Status#<br></cfoutput>