推 tomap41017:thread b call arraylist.wait() 10/04 23:02
→ tomap41017:在A thread做完之後去call arraylist.notifyAll() 10/04 23:04
→ dou0228:未看先猜 ArrayList 不是 Collections.synchronizedList() 10/05 00:41
→ dou0228:List l=Collections.synchronizedList(new ArrayList()); 10/05 00:44
→ dou0228:... synchronized(list) { ... } 10/05 00:46
→ jehovah:謝謝^^ 那請問用vector來做是否也可行? 10/05 00:48
→ dou0228:可,因為 Collections.synchronizedList 傳入 List<T> list 10/05 00:51
→ jehovah:抱歉再請教, 若為ArrayList<ArrayList<String>> 10/05 10:20
→ jehovah:則Collections.synchronizedList會確保兩層同步嗎? 10/05 10:22
→ jehovah:我測試了一下, 結果是內外獨立的 10/05 10:54
→ dou0228:內外獨立正常,兩層都要 用 Collections. 來建才會 sync. 10/05 10:55
推 dream1124:你可以用concurrent package 裡面寫好的資料結構 10/05 11:00
→ jej:要先確定起的這個物件是不是唯一的.. 不是唯一的就鎖不起來 10/06 20:54