added synchronized block around notify statements