In the "Known Attacks" section, they advocate using a mutex to prevent reentrant situations, but they're using a boolean, setting it to true before the operation and setting it to false afterwards. This is not secure -- it's possible for two threads to set it to true at the same time! You need to use an atomic concurrency operation like compare-and-swap [1] to implement a mutex.