Added synchronized block to the run method.