Adobe 38043740 - ColdFusion Standard - Mac Development Manual page 339

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

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Developing CFML Applications
Using other scopes
Threads have access to all the ColdFusion scopes. All the threads run by a page share the same Variables and This
scope. All the threads run in a request share the same Form, URL, Request, CGI, Cookie, Session, Application, Server
and Client scopes. Be careful to lock access to these scopes if more than one thread could try to modify the data in the
scopes; otherwise you can get deadlocks between threads. For more information, see
resource
access" on page 334.
Although a thread can access all the scopes, it might not be able to write to scopes like Session, Cookie, or Request after
the request page processing completes.
Scope precedence
If you do not specify a scope prefix on a variable inside a
following order to find the variable:
1
Function-local, in function definitions in the thread only
2
Thread-local
Attributes
3
Variables
4
5
Thread/cfthread
Other scopes are checked in the standard scope checking order.
Locking thread data and resource access
When an application uses multiple threads, be careful to ensure that the threads do not simultaneously attempt to use
or modify shared resources that are not themselves thread-safe, including the following items:
• If multiple threads modify a Variables or Request scope variable, use a Request scope lock to control access to the
code that uses the variable to prevent deadlocks and race conditions. Similarly, use a Request scope lock around
code that accesses built-in data structures or subscopes of the Variables scope, such as the Forms variable, that you
change in multiple threads.
• Multiple threads should not try to access any other shared resource simultaneously. For example, do not use the
same FTP connection from multiple threads. To prevent this behavior, place the code that uses the resource in
named
tags. Use the same
cflock
For more information on locking code, see
Metadata variables
The Thread scope contains the following variables that provide information about the thread, called metadata.
Variable
Description
Elapsedtime
The amount of processor time that has been spent handling the thread.
Error
A ColdFusion error structure that contains the keys that you can access in a
only if an unhandled error occurred during thread processing. For information on handling thread errors, see
"Handling ColdFusion thread
Name
The thread name.
Output
Output text that the thread generates. Threads cannot display output directly. For more information see
thread
output" on page 336.
cfthread
attribute for all
name
cflock
and
"Locking code with
cflock
errors" on page 336.
Last updated 1/20/2012
"Locking thread data and
tag body, ColdFusion checks scopes in the
tags around code that uses a specific resource.
cflock" on page 318.
cfcatch
tag. This variable has a value
334
"Handling

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 9

Table of Contents