Change relevant methods to synchronized.