Fix the sync problem of lock and timer.