如何在不使用同步块/关键字的情况下将collection.sort(list)设置为线程安全
public class IdealPriceStrategy implements ICalculate {
public BigDecimal calculate(List<BigDecimal> prices) {
BigDecimal idealPrice = BigDecimal.ZERO;
if(null!=prices){
if(prices.size() > 5) {
int size= prices.size();
Collections.sort(prices);
prices = prices.subList(2, size-2);
idealPrice = new PriceBL(prices).getAverage().multiply(BigDecimal.valueOf(1.2));
}
}
return idealPrice;
}
}