码迷,mamicode.com
首页 > 编程语言 > 详细

线程同步

时间:2014-05-28 09:38:14      阅读:205      评论:0      收藏:0      [点我收藏+]

标签:style   c   class   blog   code   java   

win32可以使用

InterlockedIncrement

InterlockedDecrement

来使同一时间只有一个线程在访问变量

 

 

bubuko.com,布布扣
 1 ULONG _stdcall CA::AddRef()
 2 {
 3     return InterlockedIncrement(&m_ref);
 4 }
 5 
 6 ULONG _stdcall CA::Release()
 7 {
 8     if (InterlockedDecrement(&m_ref) == 0)
 9     {
10         delete m_ref;]
11         return 0;
12     }  
13     return m_ref;
14 }    
bubuko.com,布布扣

 

线程同步,布布扣,bubuko.com

线程同步

标签:style   c   class   blog   code   java   

原文地址:http://www.cnblogs.com/aoun/p/3755152.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!