- see footer for list info -<
It's to dow ith race conditions.

Yes, but...

If your doing <cfset session.a = b>
The value of a or b could change before the above statement has completed, by some other page that also reads/writes the same session variables.

No. This cannot happen (since CF5), or at least not in a way that is meaningful or relevant. Java will prevent anything else writing to session.a whilst there is already a line of code accessing it. And b is a local variable, so cannot be altered by another thread. And to be honest, what you describe would not be a problem anyhow. It's exactly what would happen if two threads hit that line of code in series anyhow.

The story with race conditions is more along these lines:

<cfif not structKeyExists(session, "a")>
<!---do some stuff which you only want to do ONCE per lifespan of session.a --->

<cfset session.a = "OK, it's been done: this is set so it ain't done again.">
</cfif>

Now... one thread hits the first line, and the test passes as session.a doesn't exist. And before the first thread gets to the end of the <cfif /> block, a second thread hits the <cfif>. Again... the variable doesn't exist, so the SECOND thread also starts executing the inner block.

THAT'S a race.

One might say "well that's just dumb having the check variable set at the bottom of the <cfif /> block anyhow. This is true, but even if it was the very first line in the <cfif /> block, it's still possible that a second thread hits the <cfif> before the first thread completes the following <cfset>.

--
Adam

_______________________________________________

For details on ALL mailing lists and for joining or leaving lists, go to 
http://list.cfdeveloper.co.uk/mailman/listinfo

--
CFDeveloper Sponsors:-
- Hosting provided by www.cfmxhosting.co.uk -<
- Forum provided by www.fusetalk.com -<
- DHTML Menus provided by www.APYCOM.com -<
- Lists hosted by www.Gradwell.com -<
- CFdeveloper is run by Russ Michaels, feel free to volunteer your help -<

Reply via email to