Single Threaded Summation: Protection with Locks
If I protect access to the summation variable with a lock, I will get the answers to two questions.
- How expensive is the synchronization of a lock without contention?
- How fast can a lock be in the optimal case?
I can draw an interesting conclusion from question 2. If there is contention on a lock, the access time will decrease. That being said, I will only show the application of