Windows 与 Linux多线程函数对应表

本文详细探讨了Linux pthread API在Windows上的对应实现,如pthread_create与CreateThread、互斥锁操作等,并介绍了如何使用pthread_cond和Windows Event对象进行条件变量管理。深入理解了两者的异同,为开发者提供跨平台开发的参考。
Linux Pthread API                               Windows SDK 库对应 API

创建  pthread_create                              CreateThread
退出  pthread_exit                                ThreadExit
等待  pthread_join                                WaitForSingleObject

条件:
创建  pthread_cond_init                           CreateEvent
销毁  pthread_cond_destroy                        CloseHandle
触发  pthread_cond_signal                         SetEvent
广播  pthread_cond_broadcast                      SetEvent/ResetEvent
等待  pthread_cond_wait/pthread_cond_timedwait    SingleObjectAndWait

互斥锁:    
创建  pthread_mutex_init                          CreateMutex
销毁  pthread_mutex_destroy                       CloseHandle
加锁  pthread_mutex_lock                          WaitForSingleObject
解锁  pthread_mutex_unlock                        ReleaseMutex

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值