Home

Awesome

线程支持库

  1. 线程管理(Managing thread)<thread>
  2. 线程间共享数据(Sharing data between thread)<mutex><shared_mutex>
  3. 同步并发操作(Synchronizing concurrent operation)<condition_variable><semaphore><barrier><latch><future><chrono><ratio>
  4. C++ 内存模型和基于原子类型的操作(The C++ memory model and operations on atomic type)<atomic>

并发编程实践

  1. 基于锁的并发数据结构的设计(Designing lock-based concurrent data structure)
  2. 无锁并发数据结构的设计(Designing lock-free concurrent data structure)
  3. 并发代码的设计(Designing concurrent code)
  4. 高级线程管理(Advanced thread management)
  5. 并行算法(Parallel algorithm)<execution>
  6. 多线程应用的测试与调试(Testing and debugging multithreaded application)

标准库相关头文件

头文件说明
<thread><stop_token>线程
<mutex><shared_mutex>
<condition_variable>条件变量
<semaphore>信号量
<barrier><latch>屏障
<future>异步处理的结果
<chrono>时钟
<ratio>编译期有理数算数
<atomic>原子类型和原子操作
<execution>标准库算法执行策略

并发库对比

C++11 Thread

特性API
threadstd::thread
mutexstd::mutexstd::lock_guardstd::unique_lock
condition variablestd::condition_variablestd::condition_variable_any
atomicstd::atomicstd::atomic_thread_fence
futurestd::futurestd::shared_future
interruption

Boost Thread

特性API
threadboost::thread
mutexboost::mutexboost::lock_guardboost::unique_lock
condition variableboost::condition_variableboost::condition_variable_any
atomic
futureboost::futureboost::shared_future
interruptionthread::interrupt

POSIX Thread

特性API
threadpthread_createpthread_detachpthread_join
mutexpthread_mutex_lock、pthread_mutex_unlock
condition variablepthread_cond_waitpthread_cond_signal
atomic
future
interruptionpthread_cancel

Java Thread

特性API
threadjava.lang.Thread
mutexsynchronized blocks
condition variablejava.lang.Object.waitjava.lang.Object.notify
atomicvolatile 变量、java.util.concurrent.atomic
futurejava.util.concurrent.Future
interruptionjava.lang.Thread.interrupt
线程安全的容器java.util.concurrent 中的容器
线程池java.util.concurrent.ThreadPoolExecutor