In Adobe ColdFusion, if
<cfset Application.obj = CreateObject("component","ComponentName")>
<cfset myResult = Application.obj.FunctionName()>
I’m concerned that a var declared in the function’s local scope might have concurrency problems because Application.obj is stored in the Application scope.
<cffunction name="FunctionName">
<cfset var local = {}>
(pretend some long process happens here)
<cfif condition>
<cfset local.result = True>
<cfelse>
<cfset local.result = False>
</cfif>
<cfreturn local.result>
If two people are in that function at the same time, will the result for person 1 corrupt the result for person 2?
Yes, there is the potential for a race condition in your code sample.
You will need to use a lock around
to prevent the race condition.
The type of lock to use would depend really on what the long process is doing.
If you are instantiating your framework you might consider double-checked locking. (Joe Rinehart, author of Model-Glue had a great post on this but his site isn’t responding atm.)
If the long process is less critical you could use a simpler lock.