线程同步 win
来源:互联网 发布:java 验证日期格式 编辑:程序博客网 时间:2024/05/21 15:43
/*
只能在当前进程中使用
只能同步一个资源,要用同步多个资源需要使用 SynMultiWaite
*/
class Synchronization
{
Synchronization(): m_dwMilliseconds(500){ m_Syn = CreateMutex(NULL,false,NULL);}
Synchronization(DWORD dwMill): m_dwMilliseconds(500){ m_Syn = CreateMutex(NULL,false,NULL);}
~Synchronization() { CloseHandle(m_Syn);}
public:
/*
WAIT_ABANDONED
The specified object is a mutex object that was not released
by the thread that owned the mutex object before the owning
thread terminated. Ownership of the mutex object is granted
to the calling thread, and the mutex is set to nonsignaled.
WAIT_OBJECT_0
The state of the specified object is signaled.
WAIT_TIMEOUT
The time-out interval elapsed, and the object's state is nonsignaled.
*/
DWORD SynSingleWaite(){ return WaitForSingleObject(m_Syn,m_ulMilliseconds); }
bool SynRelease(){ return ReleaseMutex(m_Syn); }
//when use mutl
//DWORD SynMultiWaite(){ DWORD WaitForMultipleObjects();}
private:
HANDLE m_Syn;
DWORD m_dwMilliseconds;
};
- 线程同步 win
- win线程同步--循环锁简单理解
- 线程同步--线程同步--线程同步--线程同步--线程同步
- win线程等待代码
- win 线程生亡
- 线程同步
- 线程同步
- 线程同步
- 线程同步
- 线程同步
- 线程同步
- 线程同步
- 线程同步
- 线程同步
- 线程同步
- 线程同步
- 线程同步
- 线程同步
- Markdown编辑器如何配置图片大小
- WebSocket入门
- Java发送邮件工具类
- 手机IMEI
- webservice head加密
- 线程同步 win
- Hive 修改表添加分区(add partition)和 加载数据时添加分区 的区别
- Android国际化
- javascript + html5实现加载动画
- 在网站上爬取实习岗位
- 向前兼容和向后兼容
- ViewPager Fragment动态添加以及动态删除的理解
- 最大子段和问题,最大子矩阵和问题,最大m子段和问题
- Gamification MOOC 学习笔记5——动机与心理(下)