Replace MUTEX_LOCK with a timed lock.