Fix -Wthread-safety-analysis warnings
Summary: The locks were missing from D4186.
With Clang as a compiler:
cmake -GNinja .. -DCMAKE_BUILD_TYPE=Debug ninja check
Ensure there is no -Wthread-safety-analysis warning in the build
output, and all the tests are passing.
Reviewers: #bitcoin_abc, deadalnix
Reviewed By: #bitcoin_abc, deadalnix
Differential Revision: https://reviews.bitcoinabc.org/D4282