????for???????10?????????????????е??????????????????100000?Ρ??????????????????????????108494?Σ????к???????????????????????????????????Σ?

????17ticket NO??35721
????14ticket NO??35699
????11ticket NO??35721
????18ticket NO??35721
????17ticket NO??35729
????11ticket NO??35729
????14ticket NO??35729
????17ticket NO??35729
????14ticket NO??35734
????17ticket NO??35734
????13ticket NO??35721

???????????35721??35729??????????????????????????????????????????????????????????1??????ArrayList????????

??????????synchronized??????????????????????????У??????????????????????????????

    final List<String> tickets = new ArrayList<String>();
    for (int i = 0; i < 100000; i++) {
       tickets.add("ticket NO??" + i);
    }
    System.out.println("start1...");
    final Object lock=new Object();
    for (int i = 0; i < 10; i++) {
       Thread salethread = new Thread() {
           public void run() {
               while (true) {
                   synchronized(lock)
                   {
                     if(tickets.size()>0)
                       System.out.println(Thread.currentThread().getId()+ tickets.remove(0));
                     else
                        break;
                   }
               }
           }
       };
       salethread.start();
    }

????????????????????????

??????????????synchronized??????????????vector????Collections.synchronizedList ??????Ч????

    final List<String> tickets =java.util.Collections.synchronizedList(new ArrayList<String>());
    final List<String> tickets =new Vector<String>();

????vector??Collections.synchronizedList ???????????????????????????