CFLOCK Further Explained!
First, to address the question as to why the "scope" attribute hasn't been deprecated (Duncan pointed out that in CF8 they even added a scope - you can now specify "request" as a valid value). The truth is, I'm not sure why it hasn't been deprecated because, if you read the available CF 8 documentation on locking http://livedocs.adobe.com/coldfusion/8/sharedVars_01.html#1159066, it appears to be absolutely no different to a named lock - you're just using the name of a scope and specifying it via a different attribute. One possible difference is that in the case of session scope locking, it's reasonable to assume that the tag is "smart" enough to limit the lock to THAT USER'S session scope (and not effect other users' sessions). You could still achieve the same result by doing something like name="session#session.sessionid#", though. One of the things I dislike most about ColdFusion is the fact that, being a commercial product owned and controlled by a company, not enough of the details of its inner workings are explained. If someone on the CF Server team would like to clarify the difference between how CFLOCK works internally depending on whether it's named or has a scope specified, it'd be greatly appreciated.
I promised a confusing response, and that didn't seem too confusing, did it? If you took the advice I just gave and read everything in the documentation about locking variables however, then you are probably extremely confused at this point. The reason being: the documentation is in direct conflict with my statement that you don't need to lock scopes and that it's not a recommended practice. So what's the truth?
It is true that ColdFusion is thread safe - this means threads will not try to modify the same variable simultaneously. However, Adobe does not guarantee the order in which the server, which is a multi-threaded engine handling a lot of simultaneous requests (among other things), will execute those threads. In other words, while trying to read and write to the same variable with 5 simultaneous threads won't crash the server, there's no guarantee in what order those threads will execute. This can cause inconsistent/inaccurate data. Basically, take my prior discussion about race conditions and apply the same principals to server threads in an environment where extreme load is causing VERY frequent simultaneous writes/reads to the same variable. Another environment where this may be an issue is in the case of a very slow server where processing isn't measured in milliseconds. The only way Adobe will guarantee data integrity is if you lock. Now, I have some thoughts on this.
First, I'll state for the record that I've never seensuch extreme load on CFMX servers that unlocked scope access caused incorrect results... this includes one environment in which the load was so great that CF had to be all-together abandoned (yes, that's A LOT of load). I'll also say that, in an application that follows what I'd call "ColdFusion Software Architecture Best Practices"), there is a very unlikely chance of data becoming corrupt in any of the ways described in the documentation. So maybe if you write really poor code you should play it safe and use a lot of CFLOCKing (remember though, CFLOCK will slow down your app). I also think it's worth noting that in the two environments I describe where the problem is more likely to arise (that of a server under massive load and that of an extremely slow server) there is a better answer. A server under THAT much load probably means (hopefully means is more like it) that you can afford to buy more (or better) servers. In the case of a server that is taking a really long time to process threads/requests - I'd say you've got bigger problems to worry about. Either way, based on my past experience, I wouldn't use scope locking.
Hopefully, that helps to clear things up. Again, I would love for an engineer from the CF Server Team to chime in on this one.
