perl locks not just variable but the whole shared space, is it correct?Yes.
All shared variables are kept in a separate interpreter, with stub copies of the variable in each thread, and a tieing mechanism used to access the vars. So when you do something like $shared_var = 1, your thread notes that $shared_var is tied, an calls the STORE method (which happens to be implemented in XS for efficiency). This method sets a global lock and copies the new value to the 'real' variable.
Dave.
In reply to Re^4: threads::shared - when to lock a hash ?
by dave_the_m
in thread threads::shared - when to lock a hash ?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |