in reply to Re^2: Help on Understanding Locks in Multithreading
in thread Help on Understanding Locks in Multithreading
I am confused how the $foo variable is locked in the functions.Actually '$foo' itself isn't locked, execution access is locked. By that I mean that only one thread may be executing in the code blocks that have the 'lock' command at a time. And those blocks just happening to be modifying 'foo' (well, hopefully by design). The locks are controlling/limiting execution flow to a single thread at a time. This stops 2 threads from doing near simultaneous modifications to $foo.
In the old days this code was called a 'critical code section'.
|
|---|