User Guide Cancel

ThreadJoin

 

Description

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

Category

Exception handling functionsData output functions

Function syntax

ThreadJoin([threadName], [timeout])
ThreadJoin([threadName], [timeout])
ThreadJoin([threadName], [timeout])

See also

cfscriptcfthrowcftrycfcatch

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 {{threadName}}parameter complete processing, or until the period specified in the {{timeout}}parameter 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(threadNametimeout): 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>
<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>
<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>

Get help faster and easier

New user?