Ian, It looks like you're not joining your thread back to the main request's thread.
You can use cfthread to make a throw-away thread, like you're doing in your example, but if you want to use anything created in that spun-off thread, your thread either has to write to a shared scope, like application.* or session.*, or it has to join back to the main thread. http://www.cfquickdocs.com/cf8/#cfthread I think you may be looking for something like: <cfloop query="tables"> <cfthread action="join" name="thd_#table_name#" /> </cfloop> On Wed, Apr 30, 2008 at 8:48 AM, Ian Skinner <[EMAIL PROTECTED]> wrote: > What am I not getting here. > > I am attempting to use <cfthread...> to asynchronously query a database > multiple times. It seems to be doing this properly, but I am not > getting the results back out of the threads. When I run the below code > without the <cfthread...> logic it works correctly and I get the results > in the application.extdm variable. When I include the <cfthread...> > logic I only get the last result in the extdm variable. > > <cfloop query="tables"> > <cfthread action="run" name="thd_#tables.table_name#"> > <cfset var dbError = ""> > <cfset var count = queryNew('count')> > > <cftry> > <cfquery datasource="extdm" name="count"> > SELECT COUNT(*) as count > FROM #tables.owner#.#tables.table_name# > </cfquery> > > <cfcatch type="database"> > <cfset dbError = duplicate(cfcatch)> > </cfcatch> > </cftry> > > <cflock name="extdm_write" type="exclusive" timeout="5"> > <cfset > > application.extdm[arrayLen(application.extdm)]['tables'][tables.table_name] > = structNew()> > <cfset > > application.extdm[arrayLen(application.extdm)]['tables'][tables.table_name]['count'] > = count.count> > <cfset > > application.extdm[arrayLen(application.extdm)]['tables'][tables.table_name]['dbError'] > = duplicate(dbError)> > </cflock> > </cfthread> > </cfloop> > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;192386516;25150098;k Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:304519 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4