Are there any side effects visible outside of a method?
If the answer to this question is no, we can skip some heap allocation and change the scope of locks perhaps.
Note
- Lock Elision: don’t use a lock if theres no need
- Lock coarsening: make critical sections bigger to reduce lock and overhead events
Also maybe remove recursive locks.