adding synchronization block to make sure the Runnable is not inconsistent.