Created
February 11, 2019 12:57
-
-
Save l-brett/5c766984bb7d9d993837b21031151827 to your computer and use it in GitHub Desktop.
Coldfusion - Get a list of all current threads
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--- 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()> | |
<style> | |
.text { | |
padding: 1em; | |
color:white; | |
background:black; | |
margin: 1em; | |
} | |
</style> | |
<p>Number of threads: <cfoutput>#ArrayLen(keys)#</cfoutput> | |
<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> | |
</cfloop> | |
</cfoutput> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment