Fixed mutex to work with pthread.