The CFTHREAD Scope
Did you know that ColdFusion 8 has a new scope? The CFTHREAD scope is a special scope that contains information about threads in the current request.
Consider this simple example:
<cfset urls =
<cfset counter = 0>
<cfloop index="u" list="#urls#">
<cfset counter++ >
<cfthread theurl="#u#" name="thread_#counter#">
This code block creates 3 threads, named thread_1, thread_2, and thread_3. (I don't get paid to be creative!) Each thread created will exist as a structure inside the CFTHREAD scope as demonstrated in this screen shot:
You will notice that not all of my threads are finished. That is because I didn't do a join on my threads. If you look at Paragator, my ColdFusion RSS Aggregator CFC, you will see I kept a list of all threads so that I could join them. I then used Evalute to create pointers to the data. This can be done a lot easier now. So for example, to join all threads:
<cfthread action="join" name="#structKeyList(cfthread)#" />
And to get access to a thread's data:
I'll be updating Paragator a bit later in the week.
View All Articles by Raymond Camden
Our Daily Email of Breaking eBusiness News
About the Author:
Raymond Camden, email@example.com
Raymond Camden is Vice President of Technology for roundpeg, Inc. A long
time ColdFusion user, Raymond has worked on numerous ColdFusion books
and is the creator of many of the most popular ColdFusion community web
sites. He is an Adobe Community Expert, user group manager, and the
proud father of three little bundles of joy.
WebProNews RSS Feed
More Expert Articles Articles