Revert "change locking to a mutex"

This reverts commit 2050d4bb2b2b3ea642350fa12634cf2c39e61472.