并发编程概述
并发编程
并发编程领域可以抽象成三个核心问题:分工、协作和互斥。
分工
- ThreadPool/Executor
- ForkJoinPool/ForkJoinTask
- ScheduledThreadPoolExecutor
- Guarded Suspension (wait/notify)
- Balking pattern (reject)
- Messaging design pattern
协作
- Semaphore
- monitor
- Lock
- ReadWriteLock
- Condition
- synchronized
- Lock
- CountDownLatch
- CyclicBarrier
- Phaser
- Exchanger
互斥
无锁
- local variables
- immutable data structures
- TLS
- Copy-on-Write
- CAS
- atomic package
互斥锁
- synchronized
- Lock
- ReadWriteLock