|
为什么多线程导致死锁?
[QUOTE=seu人;1312294]{ HANDLE h[2]; h[0] = hAutoResetEvent1; //event 是自动的,初始信号为未触发 h[1] = hAutoResetEvent1; //event 是自动的,初始信号为未触发 waitformutipleobjects(2, h, true,...[/QUOTE] 死锁的原因是: 线程1的等待函数发现 event1 有信号,event2没有信号。 所以不会对event1对象产生任何的副作用。 接下来,event2有信号后,系统会让2个事件 都设为未触发的。 让一个线程执行。另一个线程,会继续等待。 这就防止死锁了。 如果waitformutiple不是原子操作。 比如线程1 对事件1 产生副作用后,事件1就会未触发。 线程2 对事件产生副作用后,事件2就会为触发 线程1等待 事件2 线程2 等待 事件1 造成死锁。 当然这一切,都是黑盒猜测,waitformutiple的源码没有看到。 |
|
[原创]DLL, lib静态、动态库
如果 vc 不提供这 2 个库,那么,用户恐怕就没有办法直接调用 kernel32.dll 中的Win32API 功能了! 请问,为什么? 我知道,我们一般使用 kernel32.dll的函数,几乎不是以loadlibrary的方式,而是以静态链接。 所以需要kernel32.lib这个文件。 安装多个vc版本,会提供不同的kernel32.lib, 会不会引入新问题: 不同版本的的kernel32.lib, 和同一个kernel32.dll 进行搭配。 不会有问题吗? 一般安装一些开发包,比如sdk 这些包, 或者 vc开发工具后, 都会引入kernel32.lib。 我们程序发布的时候,肯定是不会发布kenrel32.dll。 |
|
|
操作理由
RANk
{{ user_info.golds == '' ? 0 : user_info.golds }}
雪币
{{ experience }}
课程经验
{{ score }}
学习收益
{{study_duration_fmt}}
学习时长
基本信息
荣誉称号:
{{ honorary_title }}
能力排名:
No.{{ rank_num }}
等 级:
LV{{ rank_lv-100 }}
活跃值:
在线值:
浏览人数:{{ visits }}
最近活跃:{{ last_active_time }}
注册时间:{{ user_info.create_date_jsonfmt }}
勋章
兑换勋章
证书
证书查询 >
能力值