The CFLOCK tag single-threads access to the CFML constructs in its body, so that the body of the tag can be executed by at most one request at a time. A request executing inside a CFLOCK tag has an "exclusive lock" on the tag. No other requests are allowed to start executing inside the tag while a request has an exclusive lock. ColdFusion issues exclusive locks on a first-come first-serve basis.
Using CFLOCK around CFML constructs that modify shared data ensures that the modifications occur one after the other and not all at the same time. As a general rule, you should use the CFLOCK tag to perform updates to variables in the Application, Server, and Session scopes in the Application.cfm file.
|