added synchronized block. for waiting threads