Damon Cooper of Adobe has posted a proof of concept for two new tags for the ColdFusion language: CFTHREAD and CFJOIN. These tags let you fire off events and simply forget about them. Right now there is an issue where you can't "completely" forget about them, but you can still run a large set of events asynchronously. Consider this example:

<cfif not isDefined("url.slow")> <cfset good = true> <cfelse> <cfset good = false> </cfif>

<cfhttp url="http://ray.camdenfamily.com/rss.cfm" result="result"> <cfset myrss = result.filecontent> <cfset myrssParsed = xmlParse(myrss)> <cfset myurls = xmlSearch(myrssParsed, "/rss/channel/item/link/text()")> <cfset links = arrayNew(1)>

<cfloop index="x" from="1" to="#arrayLen(myurls)#"> <cfset arrayAppend(links, myurls[x].xmlvalue)> </cfloop>

<cfif good>

<cfloop index="loopcounter" from="1" to="#arrayLen(links)#"> <cfset threadname = "thread_" & loopcounter>

<cfthread name="#threadname#">

<cfhttp url="#links[loopcounter]#" result="result"> <cffile action="write" file="c:\web\url#loopcounter#.txt" output="#result.filecontent#">

</cfthread>

</cfloop>

<cfloop index="loopcounter" from="1" to="#arrayLen(links)#"> <cfset threadname = "thread_" & loopcounter> <cfjoin thread="#threadname#"> </cfloop>

<cfelse>

<cfloop index="loopcounter" from="1" to="#arrayLen(links)#"> <cfhttp url="#links[loopcounter]#" result="result"> <cffile action="write" file="c:\web\url#loopcounter#.txt" output="#result.filecontent#">

</cfloop>

</cfif>

<br> Work Complete!<br>

What I've done is written two sets of code. One shows the use of cfthread/cfjoin, and one does not. The code downloads my RSS feed and gets an array of URLs. It then fetches each URL and saves it to a file. If you compare the "good" version versus the "bad" one (load the file with slow=true in the URL), you will see an incredible speed difference, and this is even with the bug. While the threads all run at the same time, you have to wait for the threads to end, whereas in the (hopefully) final version, you would not need to.