Using a mutex with synchronous threads