文件名称:Mutex_Critical
- 所属分类:
- 进程与线程
- 资源属性:
- [Windows] [Visual C] [源码]
- 上传时间:
- 2012-11-26
- 文件大小:
- 836kb
- 下载次数:
- 1次
- 提 供 者:
- chenz*****
- 相关连接:
- 无
- 下载说明:
- 别用迅雷下载,失败请重下,重下不扣分!
介绍说明--下载内容均来自于网络,请自行研究使用
这个例子利用多线程使用不同的排序算法对数据进行排序,每一个线程使用不同的算法。主线程里使用快速排序QuickSort,其他四个算法分别建立四个子线程,在子线程中进行排序。因为每一个线程都要调用函数PrintResult把结果输出到显示器上,所以不同的线程就会争夺着向显示器输出,这样,不同线程的输出就会混合在一起,所以呢必须让线程一个接着一个输出。也就是必须对PrintResult进行互斥控
制。要进行互斥控制,则必须用到Event、Mutex、CrititicalSection、Semaphore等互斥控制量。这个例子可以使用 Event、Mutex、CrititicalSection,你可以根据提示修改代码使用其中的一种互斥量进行测试。 我所写的例子没有使用MFC,用的都是SDK的WINAPI,如果使用MFC时有些许差别,但原理是一样的。而且MFC还把线程分成用户界面线程和工作者线程,实质上用户界面线程跟工作者线程的差别是,用户界面线程要继承的基类已经实现了消息循环,MFC帮你做了很多的消息处理和界面控制的工作。 -The examples of using multiple threads to use a different sorting algorithm to sort the data, for each thread use a different algorithm. The main thread, use the quick sort QuickSort, the other four algorithms were the establishment of four sub-thread, thread in the sub-sort. Because each thread must call the function PrintResult the output to the monitor, so that different threads will compete for the output to the monitor, so that different threads of the output will be mixed together, so it must thread one by one output. That is, must be mutually exclusive control PrintResult
System. Should be mutually exclusive control, you must use Event, Mutex, CrititicalSection, Semaphore and other exclusive control of the amount. This example can use the Event, Mutex, CrititicalSection, you can modify the code prompted a mutex using one volume of testing. I do not use examples written MFC, SDK are used in the WINAPI, if slightly different when using MFC, but the principle is the same. And MFC
制。要进行互斥控制,则必须用到Event、Mutex、CrititicalSection、Semaphore等互斥控制量。这个例子可以使用 Event、Mutex、CrititicalSection,你可以根据提示修改代码使用其中的一种互斥量进行测试。 我所写的例子没有使用MFC,用的都是SDK的WINAPI,如果使用MFC时有些许差别,但原理是一样的。而且MFC还把线程分成用户界面线程和工作者线程,实质上用户界面线程跟工作者线程的差别是,用户界面线程要继承的基类已经实现了消息循环,MFC帮你做了很多的消息处理和界面控制的工作。 -The examples of using multiple threads to use a different sorting algorithm to sort the data, for each thread use a different algorithm. The main thread, use the quick sort QuickSort, the other four algorithms were the establishment of four sub-thread, thread in the sub-sort. Because each thread must call the function PrintResult the output to the monitor, so that different threads will compete for the output to the monitor, so that different threads of the output will be mixed together, so it must thread one by one output. That is, must be mutually exclusive control PrintResult
System. Should be mutually exclusive control, you must use Event, Mutex, CrititicalSection, Semaphore and other exclusive control of the amount. This example can use the Event, Mutex, CrititicalSection, you can modify the code prompted a mutex using one volume of testing. I do not use examples written MFC, SDK are used in the WINAPI, if slightly different when using MFC, but the principle is the same. And MFC
(系统自动生成,下载前可以参看下载内容)
下载文件列表
互斥类\mutex.cpp
......\调用方法.txt
sequence\sequence\Debug\sequence.exe
........\........\.....\sequence.ilk
........\........\.....\sequence.obj
........\........\.....\sequence.pch
........\........\.....\sequence.pdb
........\........\.....\StdAfx.obj
........\........\.....\vc60.idb
........\........\.....\vc60.pdb
........\........\sequence.cpp
........\........\sequence.dsp
........\........\sequence.dsw
........\........\sequence.ncb
........\........\sequence.opt
........\........\sequence.plg
........\........\StdAfx.cpp
........\........\StdAfx.h
临界区的互斥控制 - VC知识库文章_files\ads.htm
.....................................\ads_002.htm
.....................................\....data\imgad.png
.....................................\........_002\abg-zh-CN-100c-000000.png
.....................................\doc2.gif
.....................................\dotline2.gif
.....................................\earch.gif
.....................................\expansion_embed.js
.....................................\go.gif
.....................................\pic.gif
.....................................\rec1.gif
.....................................\show_ads.js
.....................................\stat.gif
.....................................\stat.htm
.....................................\style.css
.....................................\test_domain.js
.....................................\toplogo.gif
.....................................\uipower.htm
.....................................\......._data\vcads1.swf
.....................................\vckcom.gif
sequence.zip
临界区的互斥控制 - VC知识库文章.htm
sequence\sequence\Debug
........\sequence
临界区的互斥控制 - VC知识库文章_files\ads_data
.....................................\ads_data_002
.....................................\uipower_data
互斥类
sequence
临界区的互斥控制 - VC知识库文章_files
......\调用方法.txt
sequence\sequence\Debug\sequence.exe
........\........\.....\sequence.ilk
........\........\.....\sequence.obj
........\........\.....\sequence.pch
........\........\.....\sequence.pdb
........\........\.....\StdAfx.obj
........\........\.....\vc60.idb
........\........\.....\vc60.pdb
........\........\sequence.cpp
........\........\sequence.dsp
........\........\sequence.dsw
........\........\sequence.ncb
........\........\sequence.opt
........\........\sequence.plg
........\........\StdAfx.cpp
........\........\StdAfx.h
临界区的互斥控制 - VC知识库文章_files\ads.htm
.....................................\ads_002.htm
.....................................\....data\imgad.png
.....................................\........_002\abg-zh-CN-100c-000000.png
.....................................\doc2.gif
.....................................\dotline2.gif
.....................................\earch.gif
.....................................\expansion_embed.js
.....................................\go.gif
.....................................\pic.gif
.....................................\rec1.gif
.....................................\show_ads.js
.....................................\stat.gif
.....................................\stat.htm
.....................................\style.css
.....................................\test_domain.js
.....................................\toplogo.gif
.....................................\uipower.htm
.....................................\......._data\vcads1.swf
.....................................\vckcom.gif
sequence.zip
临界区的互斥控制 - VC知识库文章.htm
sequence\sequence\Debug
........\sequence
临界区的互斥控制 - VC知识库文章_files\ads_data
.....................................\ads_data_002
.....................................\uipower_data
互斥类
sequence
临界区的互斥控制 - VC知识库文章_files