Adobe 38043740 - ColdFusion Standard - Mac Development Manual page 337

Developing applications
Hide thumbs Also See for 38043740 - ColdFusion Standard - Mac:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Developing CFML Applications
<cfthread action="join" name="t1,t2,t3" timeout="6000"/>
If the
attribute value is 0, the default value, the current thread continues waiting until all joining threads
timeout
finish. In this case, if the current thread is the page thread, the page continues waiting until the threads are joined, even
if you specify a page time-out. As a general rule, specify a
Using thread data
Because multiple threads can process simultaneously within a single request, applications must ensure that data from
one thread does not improperly affect data in another thread. ColdFusion provides several scopes that you can use to
manage thread data, and a request-level lock mechanism that you use to prevent problems caused by threads that
access page-level data. ColdFusion also provides metadata variables that contain any thread-specific output and
information about the thread, such as its status and processing time.
Thread scopes
Each thread has three special scopes:
• The thread-local scope
• The Thread scope
• The Attributes scope
The thread-local scope
The thread-local scope is an implicit scope that contains variables that are available only to the thread, and exist only
for the life of the thread. Any variable that you define inside the
prefix is in the thread local scope and cannot be accessed or modified by other threads.
To create a thread-local variable, assign the variable in the
the following lines:
<cfset var index=1>
<cfset index=1>
These two lines are equivalent, with one exception: If you use the
follow the
tag, before any other CFML tags.
cfthread
The Thread scope
The Thread scope contains thread-specific variables and metadata about the thread. Only the owning thread can write
data to this scope, but the page thread and all other threads in a request can read the variable values in this scope.
Thread scope data remains available until the page and all threads that started from the page finish, even if the page
finishes before the threads complete processing.
To create a Thread scope variable, in the
example,
) as a prefix. the following examples of creating a Thread scope variable are equivalent:
myThread
<cfset Thread.myValue = 27>
<cfset myThread.myValue = 27>
To access a thread's Thread scope variables outside the thread, prefix the variable with the thread's name, as in the
following example:
<cfset nextValue=myThread.myValue + 1>
value to limit hung threads.
timeout
cfthread
tag body without specifying a scope prefix, as in
cfthread
keyword, the assignment code must immediately
var
tag body, use the keyword
cfthread
Last updated 1/20/2012
tag body without specifying a scope name
or the name of the thread (for
Thread
332

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 9

Table of Contents