public class NumberManager {
private int lastNumber = 1;
private List<Integer> queueNumbers = new ArrayList<Integer> ();
public synchronized Integer generateNewNumber(){
queueNumbers.add(++lastNumber);
return lastNumber;
}
private List<Integer> queueNumbers = new ArrayList<Integer> (); 这里是通过queueNumbers指向new生成的一个对象。为什么要私有 |