Whatever message this page gives is out now! Go check it out!
<cfthread
required
name="thread name[,thread name]..."
optional
action="join"
timeout="milliseconds"/>
run
<cfthread
required
name="thread name"
optional
action="run"
priority="NORMAL|HIGH|LOW"
zero or more application-specific attributes>
Thread code
</cfthread>
sleep
<cfthread
required
action="sleep"
duration="milliseconds"/>Attribute | Req/Opt | Default | Applies to | Description |
action | Optional | run | All | The action to take, one of the following values:
|
duration | Required | sleep | The number of milliseconds for which to suspend thread processing. | |
name | Required, if action = "join" or "interrupt" | join interrupt | The name of the thread to which the action applies:
| |
priority | Optional | NORMAL | run | The priority level at which to run the thread. The following values are valid:
|
timeout | Optional | 0 | join | The number of milliseconds that the current thread waits for the thread or threads being joined to finish. If any thread does not finish by the specified time, the current thread proceeds. If the attribute value is 0, the following action occurs:
|
Variable | Description |
ElapsedTime | The amount of processor time that was spent handling the thread. |
Error | The structure that is generated if an error occurs during thread execution. The structure contains the keys that you can access in a cfcatch tag. If an error occurs in a thread, page-level processing is not affected, and ColdFusion does not generate an error message. The thread with the error terminates and the page-level code or other threads can get the error information from the Error field and handle the error appropriately. For detailed information, see Handling ColdFusion thread errors in Working with threads in the Developing ColdFusion Applications. |
Name | The thread name. |
Output | Output that is generated by the thread. A thread cannot display output; page-level code must use this variable to display thread results. For detailed information, see Handling thread output in Working with threads in the Developing ColdFusion Applications. |
Priority | The thread processing priority, as specified in the cfthread priority attribute. The following values are valid:
|
Starttime | The time at which the thread began processing, in ColdFusion date-time format. |
Status | The current status of the thread; one of the following values:
|
<cfif isDefined("Form.submit")>
<cfloop index="i" from="1" to="3">
<!--- Use array notation and string concatenation to create a variable
for this feed. --->
<cfset theFeed = Form["Feed"&i]>
<cfif theFeed NEQ "">
<!--- Use a separate thread to get each of the feeds. --->
<cfthread action="run" name="t#i#" feed="#theFeed#">
<cffeed source="#feed#"
properties="thread.myProps"
query="thread.myQuery">
</cfthread>
<cfelse>
<!--- If the user didn't fill all fields, show an error message. --->
<h3>This example requires three feeds.<br />
Click the Back button and try again.</h3>
<cfabort>
</cfif>
</cfloop>
<!--- Join the three threads. Use a 6 second time-out. --->
<cfthread action="join" name="t1,t2,t3" timeout="6000" />
<!--- Use a loop to display the results from the feeds. --->
<cfloop index="i" from="1" to="3">
<!--- Use the cfthread scope and associative array notation to get the
Thread scope dynamically. --->
<cfset feedResult=cfthread["t#i#"]>
<!--- Display feed information only if you got items,
for example the feed must complete before the join. --->
<cfif isDefined("feedResult.myQuery")>
<cfoutput><h2>#feedResult.myProps.title#</h2></cfoutput>
<cfoutput query="feedResult.myQuery">
<p><a href="#RSSLINK#">#TITLE#</a></p>
</cfoutput>
</cfif>
</cfloop>
</cfif>
<!--- The form for entering the feeds to aggregate. --->
<cfform>
<h3>Enter three RSS Feeds</h3>
<cfinput type="text" size="100" name="Feed1" validate="url"
value="http://rss.adobe.com/events.rss?locale=en"><br />
<cfinput type="text" size="100" name="Feed2" validate="url"
value="http://weblogs.macromedia.com/dev_center/index.rdf"><br />
<cfinput type="text" size="100" name="Feed3" validate="url"
value="http://rss.adobe.com/studio.rss?locale=en"><br />
<cfinput type="submit" name="submit">
</cfform>