proper mutexing of shared data structures for thread protection