where it went wrong?
Nothing went wrong.
The only thing that might have stopped the second thread from modifying the variable, is if that second thread had attempted to acquire the lock. Which would have blocked until the first thread completed its sleep and exited its block thus releasing the lock.
Either way, count will only ever be incremented once.
In reply to Re: threads::shared: lock a VARIABLE
by BrowserUk
in thread threads::shared: lock a VARIABLE
by freakcoco
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |