Converting synchronized to lock