Skip to content

Instantly share code, notes, and snippets.

@l-brett l-brett/threads.cfm
Created Feb 11, 2019

What would you like to do?
Coldfusion - Get a list of all current threads
<!--- Create the thread object --->
<cfobject type="JAVA" action="Create" name="thread" class="java.lang.Thread">
<!--- Get all stack traces from the thread object --->
<cfset stackTraces = thread.getAllStackTraces()>
<!--- Convert the keySet to an array --->
<cfset keys = stackTraces.keySet().toArray()>
.text {
padding: 1em;
margin: 1em;
<p>Number of threads: <cfoutput>#ArrayLen(keys)#</cfoutput>
<!--- Loop over the keys array --->
<cfloop from="1" to="#ArrayLen(keys)#" index="sIndex">
<!--- Get the current thread --->
<cfset thisThread = keys[sIndex]>
<!--- Output the current thread name --->
<p class="text"><cfdump var="#thisThread.getName()#" /></p>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.