【发布时间】:2019-10-09 04:01:55
【问题描述】:
在 Lucee v5.2.9.31 中,当我从 cfthread 对象请求 test_thread 线程的状态时,以下代码会在 checkTest 线程内部引发错误。我得到的错误是key [test_thread] doesn't exist。
<cfthread action="run" name="test_thread">
<cfloop index='i' from='1' to='50'>
<cffile action="append" file="./test_thread.txt" addNewLine="yes" output="Index: #i#" />
<cfset sleep(500) />
</cfloop>
</cfthread>
<cfthread action="run" name="checkTest">
<cfset test_thread_complete = false />
<cfloop condition="test_thread_complete eq false">
<cfset test_thread_status = cfthread['test_thread'].status />
<cffile action="append" file="./checkTestThread.txt" addNewLine="yes" output="#test_thread_status#" />
<cfif test_thread_status eq 'COMPLETED'>
<cfset test_thread_complete = true />
</cfif>
<cfset sleep(1000) />
</cfloop>
</cfthread>
<cfdump var="#cfthread#" />
<cfdump var="#cfthread['test_thread']#" />
但是在旧版本的 Lucee (v4.5.5.015) 中,代码按预期工作并生成 2 个文件:带有递增索引的 test_thread.txt,以及包含 test_thread 状态的 checkTestThread.txt。
在这两个版本中,cfdump 都返回 cfthread 对象。第一个转储包含两个线程,第二个转储只包含预期的 test_thread 对象。
这是 Lucee 5 中的错误还是代码利用了早期版本的 Lucee/Railo 中的错误?
【问题讨论】: