#vulnerable code 
                             public HistogramMetric calculateMetric() {
		// 快照当前的数据，在计算时不阻塞新的metrics update.
		List<Long> snapshotList = null;

		synchronized (lock) {
			snapshotList = measurements;
			measurements = new LinkedList();
		}

		if (snapshotList.isEmpty()) {
			return createEmptyMetric();
		}

		// 按数值大小排序，以快速支持百分比过滤
		Collections.sort(snapshotList);

		int count = snapshotList.size();

		HistogramMetric metric = new HistogramMetric();
		metric.min = snapshotList.get(0);
		metric.max = snapshotList.get(count - 1);

		double sum = 0;
		for (long value : snapshotList) {
			sum += value;
		}
		metric.mean = sum / count;

		for (Double pct : pcts) {
			metric.pcts.put(pct, getPercent(snapshotList, count, pct));
		}

		snapshot = metric;
		return metric;
	} 
                            #location 33 
                            #vulnerability type THREAD_SAFETY_VIOLATION
#fixed code
                             public HistogramMetric calculateMetric() {
		// 快照当前的数据，在计算时不阻塞新的metrics update.
		List<Long> snapshotList = measurements;

		measurements = new LinkedList();

		if (snapshotList.isEmpty()) {
			return createEmptyMetric();
		}

		// 按数值大小排序，以快速支持百分比过滤
		Collections.sort(snapshotList);

		int count = snapshotList.size();

		HistogramMetric metric = new HistogramMetric();
		metric.min = snapshotList.get(0);
		metric.max = snapshotList.get(count - 1);

		double sum = 0;
		for (long value : snapshotList) {
			sum += value;
		}
		metric.mean = sum / count;

		for (Double pct : pcts) {
			metric.pcts.put(pct, getPercent(snapshotList, count, pct));
		}

		latestMetric = metric;
		return metric;
	}