Refactor. And add lock_with_timeout demo.