Reply to comment

Good point

You are correct. That could cause a race condition. Anytime a shared resource is accessed twice, it could have a different value. Unfortunately, the place to put the lock is in the shared resource, not the caller. So there is nothing that MakeCommand could do to prevent the race condition.

If you need to access a shared resource in MakeCommand, I recommend putting a redundant check in Do. Copy the value into a local variable first so that it won't change before you act upon it.


By submitting this form, you accept the Mollom privacy policy.