Here are the results of my investigation so far on Railo 3.1.2, CF 8
and CF 9. I don't have OpenBD installed on this box, so I'll ask
someone else to investigate that.
Basic test code:
<cfoutput>
#createObject("java","java.lang.Thread").currentThread().getThreadGroup().getName()#
</cfoutput>
<cfthread action="run" name="mythread">
<cfscript>
var Thread = createObject("java","java.lang.Thread");
</cfscript>
<cffile action="write" file="C:\threadname.txt"
output="#Thread.currentThread().getThreadGroup().getName()#">
</cfthread>
Results in
Railo: same name for both the page thread and the spawned thread (both
called "main")
CF 8: "jrpp" for page thread and "cfthread" for spawned thread
CF 9 (built in webserver): "web" for page thread and "cfthread" for
spawned thread.
I did find a way with Railo, however, to tell if you are in a cfthread
or not. Railo has a function called hasFamily() of off
GetPageContext() So in Railo, the following code:
<cfdump var="#GetPageContext().hasFamily()#">
<cfthread action="run" name="mythread">
<cfset ThreadHasFamily = GetPageContext().hasFamily() />
<cffile action="write" file="C:\threadinfo.txt" output="#ThreadHasFamily#">
</cfthread>
results in "False" on the main page thread and "True" inside the
spawned thread. I could not find a comparable function in ACF after
poking around their implementation of GetPageContext()
So thus far it looks like the best way to check is to check the Thread
Group name for ACF and to check GetPageContext.hasFamily() for Railo.
Not terribly clean or consistent, alas, but the best I can do so far.
Cheers,
Judah