Thread Safe state handling, using synchronized object(mutex) as a lock.