??????????Java??????
???????????? ???????[ 2013/2/27 9:59:38 ] ????????
????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 ???????????????????????????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11