我在 ColdFusion 中有一个循环应用程序 ID 列表的例程。在该列表中,发生了许多事情,包括 PDF 文档的生成和合并。这变得非常慢,所以我看了一下 cfthread 可以为我做什么。结果很有希望;40 秒的运行时间减少到 4 秒。
然而,cfthread 本质上是不知道循环在做什么。这是一个代码示例。
<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" />
最终发生的是每次循环迭代都会重复列表中的最后一个值。那么我到底需要做什么才能完成这项工作呢?
谢谢!