thread synchronization using mutex