文件名称:BCB多线程
介绍说明--下载内容来自于网络,使用问题请自行百度
程序的执行原理是这样的,一个多线程里面包含了读和写test.txt记事本的功能。
因为读写记事本的消耗时间很短,在写记事本里面故意加了2s延时以造成多线程的明显冲突。本多线程是使用的临界区:CRITICAL_SECTION。按下按钮,通知线程要写入一串字符(线程执行完需要2s以上),延时20ms后通知线程再写入一串字符,跟第一次写入造成“冲突”,延时20ms后,在两个写都没完成时再通知线程要读同一个记事本。
因此造成线程中三个事件“打架”。(Procedures for the implementation of the principle is like this, a multi-threaded, which contains the reading and writing test.txt Notepad function.
Because the time spent reading and writing Notepad is very short, in writing Notepad, deliberately added 2S delay, resulting in obvious conflicts of multi-threaded. This multithreading is the critical area used: CRITICAL_SECTION. Press the button, thread to write a string of characters (the thread executing need more than 2S), 20ms after the delay notification thread and then write a string of characters, with the first written by "conflict", 20ms after the delay, in two did not complete the write again when the thread to read with a notebook.Thus causing three events in the thread to "fight"".)
因为读写记事本的消耗时间很短,在写记事本里面故意加了2s延时以造成多线程的明显冲突。本多线程是使用的临界区:CRITICAL_SECTION。按下按钮,通知线程要写入一串字符(线程执行完需要2s以上),延时20ms后通知线程再写入一串字符,跟第一次写入造成“冲突”,延时20ms后,在两个写都没完成时再通知线程要读同一个记事本。
因此造成线程中三个事件“打架”。(Procedures for the implementation of the principle is like this, a multi-threaded, which contains the reading and writing test.txt Notepad function.
Because the time spent reading and writing Notepad is very short, in writing Notepad, deliberately added 2S delay, resulting in obvious conflicts of multi-threaded. This multithreading is the critical area used: CRITICAL_SECTION. Press the button, thread to write a string of characters (the thread executing need more than 2S), 20ms after the delay notification thread and then write a string of characters, with the first written by "conflict", 20ms after the delay, in two did not complete the write again when the thread to read with a notebook.Thus causing three events in the thread to "fight"".)
(系统自动生成,下载前可以参看下载内容)
下载文件列表
ThreadTxt.h
Unit1.cpp
Unit1.dfm
Unit1.h
WRtext.bcc32pch
WRtext.bpr
WRtext.cpp
WRtext.exe
WRtext.res
说明.txt
ThreadTxt.cpp
Unit1.cpp
Unit1.dfm
Unit1.h
WRtext.bcc32pch
WRtext.bpr
WRtext.cpp
WRtext.exe
WRtext.res
说明.txt
ThreadTxt.cpp
本网站为编程资源及源代码搜集、介绍的搜索网站,版权归原作者所有! 粤ICP备11031372号
1999-2046 搜珍网 All Rights Reserved.