Added timeout to mutex locking