- Use Synchronize access to shared mutable data
- synchronize除了用來防止同時更改資料,也是用來保證會讀取到最新資料
- synchronize要設在get與update
- volatile - 不要過度使用Synchronize
- alien => 只synchronize必要的部份, synchoronize越少越好 open call
- 使用CopyOnWriteArrayList/Set
- 讓client決定是否synchronize, 除非你自己有把握做的更好
- static field一定要synchronize - Prefer executors
- ExecutorService提供許多好用的機制 - Prefer concurrency utilities to wait and notify
- ExecutorService
- Concurrent collections
- CountDownLatch / Semaphore, CyclicBarrier / Exchanger
- The standard idiom for using the wait method
- Private lock object idiom - Any program that relies on the
thread scheduler for correctness or performance is likely to be nonportable - thread groups are obsolete
About Me
星期一, 8月 11, 2008
Effective Java - Chapter 10 Concurrency
訂閱:
張貼留言 (Atom)


0 意見:
張貼留言