I have a routine in ColdFusion that loops over a list of application IDs. Inside that list, many things happen, including the generation and merging of PDF docs. This gets very slow so I took a look at what cfthread can do for me. The results are promising; a 40 second run time is reduced to 4 seconds.
However, cfthread, as is its nature, has no idea of what the loop is doing. Here's a code sample.
<cfloop list="#form.User_Id#" index="x">
<cfthread name="thread#x#" action="run" index="#x#">
<cfdocument format="PDF" name="report" filename="#fileToDownload#" overwrite="yes">
<cfdocumentsection>
<cfquery name="example" datasource="DS">
SELECT * FROM Table
WHERE ID = #x#
</cfquery>
<cfoutput query="example">
All the output
</cfoutput>
</cfdocumentsection>
</cfthread>
</cfloop>
<cfthread action="join" />
What ends up happening is that every loop iteration repeats the last value in the list. So what on earth do I need to do to make this work?
Thanks!