using mutex variables to synchronize multiple threads