Mutex_Critical

所属分类:进程与线程
开发工具:Visual C++
文件大小:836KB
下载次数:11
上传日期:2010-09-21 14:33:40
上 传 者vanking
说明:  这个例子利用多线程使用不同的排序算法对数据进行排序,每一个线程使用不同的算法。主线程里使用快速排序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 )

文件列表:
互斥类\mutex.cpp (373, 2010-09-20)
互斥类\调用方法.txt (290, 2010-09-20)
sequence\sequence\Debug\sequence.exe (176213, 2010-09-20)
sequence\sequence\Debug\sequence.ilk (181284, 2010-09-20)
sequence\sequence\Debug\sequence.obj (12200, 2010-09-20)
sequence\sequence\Debug\sequence.pch (1930944, 2010-09-20)
sequence\sequence\Debug\sequence.pdb (361472, 2010-09-20)
sequence\sequence\Debug\StdAfx.obj (55340, 2010-09-20)
sequence\sequence\Debug\vc60.idb (82944, 2010-09-20)
sequence\sequence\Debug\vc60.pdb (176128, 2010-09-20)
sequence\sequence\sequence.cpp (13681, 2001-10-24)
sequence\sequence\sequence.dsp (4554, 2001-10-24)
sequence\sequence\sequence.dsw (539, 2001-10-17)
sequence\sequence\sequence.ncb (33792, 2010-09-20)
sequence\sequence\sequence.opt (48640, 2010-09-20)
sequence\sequence\sequence.plg (1763, 2010-09-20)
sequence\sequence\StdAfx.cpp (295, 2001-10-17)
sequence\sequence\StdAfx.h (791, 2001-10-24)
临界区的互斥控制 - VC知识库文章_files\ads.htm (3955, 2010-09-20)
临界区的互斥控制 - VC知识库文章_files\ads_002.htm (4494, 2010-09-20)
临界区的互斥控制 - VC知识库文章_files\ads_data\imgad.png (26913, 2010-09-20)
临界区的互斥控制 - VC知识库文章_files\ads_data_002\abg-zh-CN-100c-000000.png (1104, 2010-09-20)
临界区的互斥控制 - VC知识库文章_files\doc2.gif (72, 2010-09-20)
临界区的互斥控制 - VC知识库文章_files\dotline2.gif (43, 2010-09-20)
临界区的互斥控制 - VC知识库文章_files\earch.gif (1190, 2010-09-20)
临界区的互斥控制 - VC知识库文章_files\expansion_embed.js (42810, 2010-09-20)
临界区的互斥控制 - VC知识库文章_files\go.gif (935, 2010-09-20)
临界区的互斥控制 - VC知识库文章_files\pic.gif (719, 2010-09-20)
临界区的互斥控制 - VC知识库文章_files\rec1.gif (56, 2010-09-20)
临界区的互斥控制 - VC知识库文章_files\show_ads.js (52559, 2010-09-20)
临界区的互斥控制 - VC知识库文章_files\stat.gif (43, 2010-09-20)
临界区的互斥控制 - VC知识库文章_files\stat.htm (2364, 2010-09-20)
临界区的互斥控制 - VC知识库文章_files\style.css (1097, 2010-09-20)
临界区的互斥控制 - VC知识库文章_files\test_domain.js (52, 2010-09-20)
临界区的互斥控制 - VC知识库文章_files\toplogo.gif (63, 2010-09-20)
临界区的互斥控制 - VC知识库文章_files\uipower.htm (781, 2010-09-20)
临界区的互斥控制 - VC知识库文章_files\uipower_data\vcads1.swf (13784, 2010-09-20)
临界区的互斥控制 - VC知识库文章_files\vckcom.gif (1011, 2010-09-20)
sequence.zip (8242, 2010-09-20)
临界区的互斥控制 - VC知识库文章.htm (30108, 2010-09-20)
... ...

近期下载者

相关文件


收藏者