| 订阅 | 在线投稿
分享
 
 
当前位置: 王朝网络 >> delphi >> WIN32 xia DELPHI zhong de duo xian cheng 【 tong bu 1】( si )

WIN32 xia DELPHI zhong de duo xian cheng 【 tong bu 1】( si )

2006-12-11 21:23:45 编辑來源:互联网 评论
 
 
 
本文为【WIN32下DELPHI中的多线程【同步1】(四)】的拼音翻译版
  xian cheng de tong bu
   zai shi yong de shi hou , duo xian cheng zui rang ren tou teng de ye xu jiu shi tong bu le 。
   ru guo ni de xian cheng zhi shi wan cheng yi jian bing bu xu yao fang wen xian cheng dui xiang wai bu zi yuan de gong zuo , zai zhe zhong qing kuang xia , xian cheng hu xiang zhi jian bu xu yao jin xing tong xin , ci shi Windows de yun xing xing neng zui hao 。 dan shi , xian cheng hen shao neng gou zai suo you de shi jian dou du li di jin xing cao zuo 。 tong chang qing kuang xia , yao sheng cheng yi xie xian cheng lai chu li mou ge ren wu 。 dang zhe ge ren wu wan cheng shi , ling yi ge xian cheng bi xu le jie zhe ge qing kuang 。
   xi tong zhong de suo you xian cheng dou bi xu yong you dui ge zhong xi tong zi yuan de fang wen quan , zhe xie zi yuan bao kuo nei cun dui zhan , wen jian , chuang kou he xu duo qi ta zi yuan 。 ru guo yi ge xian cheng xu yao du zhan dui zi yuan de fang wen quan , na me qi ta xian cheng jiu wu fa wan cheng ta men de gong zuo 。 fan guo lai shuo , ye bu neng rang ren he yi ge xian cheng zai ren he shi jian dou neng fang wen suo you de zi yuan 。 ru guo zai yi ge xian cheng cong nei cun kuai zhong du qu shu ju shi , ling yi ge xian cheng que xiang yao jiang shu ju xie ru tong yi ge nei cun kuai , na me zhe jiu xiang ni zai du yi ben shu shi ling yi ge ren que zai xiu gai shu zhong de nei rong yi yang 。 zhe yang , shu zhong de nei rong jiu hui bei gao de luan qi ba zao , jie guo shen me ye kan bu qing chu 。
   xian cheng xu yao zai xia mian liang zhong qing kuang xia hu xiang jin xing tong xin :
   • dang you duo ge xian cheng fang wen gong xiang zi yuan er bu shi zi yuan bei po huai shi 。
   • dang yi ge xian cheng xu yao jiang mou ge ren wu yi jing wan cheng de qing kuang tong zhi ling wai yi ge huo duo ge xian cheng shi 。
   xian cheng de tong bu bao kuo xu duo fang mian de nei rong ,Windows ti gong le xu duo fang fa , ke yi fei chang rong yi di shi xian xian cheng de tong bu 。 dan shi , yao xiang sui shi le jie yi lian chuan de xian cheng xiang yao zuo shen me , na shi fei chang kun nan de 。 wo men de tou nao de gong zuo bu shi yi bu de , wo men xi wang yi yi zhong you xu de fang shi lai si kao xu duo shi qing , mei ci qian jin yi bu 。 bu guo duo xian cheng huan jing bu shi zhe yang yun xing de 。 ni ji hu wu fa wan quan zhi dao mu biao xi tong zhong cun zai duo shao xian cheng , ye bu zhi dao ta men chu zai shen me zhuang tai xia , geng bu zhi dao ta men yao gan shen me 。
  yong hu fang shi xia de xian cheng tong bu
  1、 hu suo han shu
  zai MSDN guan yu tong bu han shu de bang zhu wen dang zhong , ni hui kan dao da liang de hu suo han shu 。 ta men da duo yi Interlocked**** de ming zi cun zai 。 hu suo han shu yun xing zai yong hu mo shi 。 ta neng bao zheng dang yi ge xian cheng fang wen yi ge bian liang shi , qi ta xian cheng wu fa fang wen ci bian liang , yi que bao bian liang zhi de wei yi xing 。 zhe zhong fang wen fang shi bei cheng wei yuan zi fang wen 。
  chang yong de hu suo han shu ji qi gong neng jian ru xia lie biao :
  
  
   han shu
   shen shu he gong neng
  
  
   InterlockedIncrement
   shen shu wei PLONG lei xing 。 ci han shu shi yi ge LONG bian liang zeng 1
  
  
   InterlockedDecrement
   shen shu wei PLONG lei xing 。 ci han shu shi yi ge LONG bian liang jian 1
  
  
   InterlockedExchangeAdd
   shen shu 1 wei PLONG lei xing , shen shu 2 wei LONG lei xing 。 ci han shu jiang shen shu 2 fu gei shen shu 1 zhi xiang de zhi
  
  
   InterlockedExchange
   shen shu 1 wei PLONG lei xing , shen shu 2 wei LONG lei xing 。 ci han shu jiang shen shu 2 de zhi fu gei shen shu 1 zhi xiang de zhi
  
  
   InterlockedExchangePointer
   shen shu wei PVOID* lei xing , shen shu 2 wei PVOID lei xing 。 ci han shu gong neng tong shang 。
  
  
   yong InterlockedExchangeAdd lai shuo ming , ta jie shou yi ge chang zheng xing bian liang de di zhi , ran hou jiang shen shu 2 de shu zhi jia dao shen shu 1 zhi ding de chang zheng xing shu ju shang 。 wo men qian bian yi jing shuo le , ta neng bao zheng dang yi ge xian cheng fang wen ci chang zheng xing bian liang shi , qi ta xian cheng wu fa fang wen ci bian liang , na me ta shi ru he shi xian de ne ? da an qu jue yu yun xing de shi he zhong CPU ping tai 。 dui yu x86 jia zu de CPU lai shuo , hu suo han shu hui dui zong xian fa chu yi ge ying jian xin hao , fang zhi ling yi ge CPU fang wen tong yi ge nei cun di zhi 。 zai Alpha ping tai shang , hu suo han shu neng gou zhi xing xia lie cao zuo
  1) da kai C P U zhong de yi ge te shu de wei biao zhi , bing zhu ming bei fang wen de nei cun di zhi 。
  2) jiang nei cun de zhi du ru yi ge ji cun qi 。
  3) xiu gai gai ji cun qi 。
  4) ru guo C P U zhong de te shu wei biao zhi shi guan bi de , ze zhuan ru di er bu 。 fou ze , te shu wei biao zhi reng ran shi da kai de , ji cun qi de zhi chong xin cun ru nei cun 。
   hu suo han shu gong zuo yu yong hu mo shi zhi xia , suo yi ta de su du shi fei chang kuai dian de 。 you li jiu you bi , hu suo han shu zui da de que dian mo guo yu shi yong fan wei de xia ai xing le , ta geng duo de zhi shi dui dan ge bian liang de bao hu 。
  2、 lin jie qu
   ye you de di fang jiao ta guan jian dai ma duan 。 lin jie qu zhi yi ge xiao dai ma duan , zai dai ma neng gou zhi xing qian , ta bi xu du zhan dui mou xie gong xiang zi yuan de fang wen quan 。 zhe shi rang ruo gan xing dai ma neng gou “ yi yuan zi cao zuo fang shi ” lai shi yong zi yuan de yi zhong fang fa 。 suo wei yuan zi cao zuo fang shi , shi zhi gai dai ma zhi dao mei you bie de xian cheng yao fang wen gai zi yuan 。 jian dan de shuo , jiu shi yi ci zhi neng you yi ge xian cheng lai zhi xing de yi duan dai ma 。
   xian lai kan yi duan li zi , zai li zi zhong , xian cheng wan cheng dui yi ge shu zu chu shi hua de gong zuo , mu biao shi zai dang qian de shu zhi shang jia 1,TThread dui xiang zhong huan ding yi le yi ge FUseCritical de bian liang , ta yong lai jue ding xian cheng zai zhi xing shi shi fou yao shi yong lin jie qu de fang shi 。
WIN32下DELPHI中的多线程【同步1】(四)
WIN32下DELPHI中的多线程【同步1】(四)
...{
WIN32下DELPHI中的多线程【同步1】(四)
zuo zhe :wudi_1982
WIN32下DELPHI中的多线程【同步1】(四)
lian xi fang shi :wudi_1982@hotmail.com
WIN32下DELPHI中的多线程【同步1】(四)
ben dai ma wei yan shi dai ma , zhi tie chu le yi xie bi jiao chong yao de dai ma
WIN32下DELPHI中的多线程【同步1】(四)
zhuan zai qing zhu ming chu chu
WIN32下DELPHI中的多线程【同步1】(四)
}
WIN32下DELPHI中的多线程【同步1】(四)

WIN32下DELPHI中的多线程【同步1】(四)
const
WIN32下DELPHI中的多线程【同步1】(四)
MaxArray = 1000;// gong gong nei cun qu yu de da xiao
WIN32下DELPHI中的多线程【同步1】(四)

WIN32下DELPHI中的多线程【同步1】(四)
// yan shi lin jie qu gong neng de xian cheng lei
WIN32下DELPHI中的多线程【同步1】(四)
type
WIN32下DELPHI中的多线程【同步1】(四)
TCriticalSectionThread= class(TThread)
WIN32下DELPHI中的多线程【同步1】(四)
private
WIN32下DELPHI中的多线程【同步1】(四)
FUseCritical : Boolean;// jue ding shi fou shi yong lin jie qu
WIN32下DELPHI中的多线程【同步1】(四)
procedure GetRestult;
WIN32下DELPHI中的多线程【同步1】(四)
protected
WIN32下DELPHI中的多线程【同步1】(四)
procedure Execute;override;
WIN32下DELPHI中的多线程【同步1】(四)
public
WIN32下DELPHI中的多线程【同步1】(四)
constructor Create(UseCritical : Boolean);
WIN32下DELPHI中的多线程【同步1】(四)
end;
WIN32下DELPHI中的多线程【同步1】(四)
end;
WIN32下DELPHI中的多线程【同步1】(四)

WIN32下DELPHI中的多线程【同步1】(四)
....
WIN32下DELPHI中的多线程【同步1】(四)

WIN32下DELPHI中的多线程【同步1】(四)
var
WIN32下DELPHI中的多线程【同步1】(四)
PublicMem : array[0..MaxArray] of integer;// yi kuai gong gong qu yu
WIN32下DELPHI中的多线程【同步1】(四)
Cs : TRTLCriticalSection;// miao shu lin jie qu xin xi de shu ju jie gou
WIN32下DELPHI中的多线程【同步1】(四)

WIN32下DELPHI中的多线程【同步1】(四)
shi xian dai ma ru xia :
WIN32下DELPHI中的多线程【同步1】(四)
WIN32下DELPHI中的多线程【同步1】(四)
...{ TCriticalSectionThread }
WIN32下DELPHI中的多线程【同步1】(四)

WIN32下DELPHI中的多线程【同步1】(四)
constructor TCriticalSectionThread.Create(UseCritical: Boolean);
WIN32下DELPHI中的多线程【同步1】(四)
begin
WIN32下DELPHI中的多线程【同步1】(四)
// gou zao han shu zhong jie shou shi fou shi yong lin jie qu de shen shu
WIN32下DELPHI中的多线程【同步1】(四)
FUseCritical := UseCritical;
WIN32下DELPHI中的多线程【同步1】(四)
inherited Create(false);
WIN32下DELPHI中的多线程【同步1】(四)
end;
WIN32下DELPHI中的多线程【同步1】(四)

WIN32下DELPHI中的多线程【同步1】(四)
procedure TCriticalSectionThread.Execute;
WIN32下DELPHI中的多线程【同步1】(四)
var
WIN32下DELPHI中的多线程【同步1】(四)
i : integer;
WIN32下DELPHI中的多线程【同步1】(四)
begin
WIN32下DELPHI中的多线程【同步1】(四)
inherited;
WIN32下DELPHI中的多线程【同步1】(四)
// yun xing wan bi hou zi dong shi fang zi yuan
WIN32下DELPHI中的多线程【同步1】(四)
FreeOnTerminate := True;
WIN32下DELPHI中的多线程【同步1】(四)
// ru guo shi yong le lin jie qu , ze jin ru lin jie qu
WIN32下DELPHI中的多线程【同步1】(四)
if FUseCritical then
WIN32下DELPHI中的多线程【同步1】(四)
EnterCriticalSection(cs);
WIN32下DELPHI中的多线程【同步1】(四)
// dui shu zu chu shi hua
WIN32下DELPHI中的多线程【同步1】(四)
for i := 0 to MaxArray do
WIN32下DELPHI中的多线程【同步1】(四)
inc(PublicMem[i]);
WIN32下DELPHI中的多线程【同步1】(四)
Synchronize(GetRestult);
WIN32下DELPHI中的多线程【同步1】(四)
// li kai
WIN32下DELPHI中的多线程【同步1】(四)
if FUseCritical then
WIN32下DELPHI中的多线程【同步1】(四)
LeaveCriticalSection(Cs);
WIN32下DELPHI中的多线程【同步1】(四)
end;
WIN32下DELPHI中的多线程【同步1】(四)

WIN32下DELPHI中的多线程【同步1】(四)
procedure TCriticalSectionThread.GetRestult;
WIN32下DELPHI中的多线程【同步1】(四)
var
WIN32下DELPHI中的多线程【同步1】(四)
i : integer;
WIN32下DELPHI中的多线程【同步1】(四)
begin
WIN32下DELPHI中的多线程【同步1】(四)
// jiang jie guo xian shi zai Form1.listbox1 zhong
WIN32下DELPHI中的多线程【同步1】(四)
for i := 0 to MaxArray do
WIN32下DELPHI中的多线程【同步1】(四)
Form1.ListBox1.Items.Add(inttostr(PublicMem[i]));
WIN32下DELPHI中的多线程【同步1】(四)
end;
WIN32下DELPHI中的多线程【同步1】(四)

WIN32下DELPHI中的多线程【同步1】(四)
// tiao yong zhe ge xian cheng lei lai yan shi lin jie qu gong neng de dai ma
WIN32下DELPHI中的多线程【同步1】(四)
procedure TForm1.Button3Click(Sender: TObject);
WIN32下DELPHI中的多线程【同步1】(四)
begin
WIN32下DELPHI中的多线程【同步1】(四)
// jiang gong gong nei cun qu yu tian chong wei 0
WIN32下DELPHI中的多线程【同步1】(四)
FillMemory(@PublicMem,sizeof(PublicMem),0);
WIN32下DELPHI中的多线程【同步1】(四)
ListBox1.Clear;
WIN32下DELPHI中的多线程【同步1】(四)
// yi ge CheckBox, yong lai jie shou shi fou shi yong lin jie qu fang shi de xin xi
WIN32下DELPHI中的多线程【同步1】(四)
if ckbxUsesC.Checked then
WIN32下DELPHI中的多线程【同步1】(四)
// ru guo shi yong lin jie qu , ze shou xian chu shi hua
WIN32下DELPHI中的多线程【同步1】(四)
InitializeCriticalSection(cs);
WIN32下DELPHI中的多线程【同步1】(四)
// tong shi sheng cheng liang ge xian cheng
WIN32下DELPHI中的多线程【同步1】(四)
TCriticalSectionThread.Create(ckbxUsesC.Checked);
WIN32下DELPHI中的多线程【同步1】(四)
TCriticalSectionThread.Create(ckbxUsesC.Checked);
WIN32下DELPHI中的多线程【同步1】(四)
end;
WIN32下DELPHI中的多线程【同步1】(四)

WIN32下DELPHI中的多线程【同步1】(四)
// hao de bian ma xi guan zhong , ni ying gai zai que ding xian cheng yi jing bu zai xu yao shi yong lin jie qu shi , yong DeleteCriticalSection(cs); qing chu zhe ge jie gou
WIN32下DELPHI中的多线程【同步1】(四)

WIN32下DELPHI中的多线程【同步1】(四)

   zheng li shang mian dai ma , bing zhi xing , zai MaxArray ding yi bi jiao da de shi hou ( ye jiu shi yi ge xian cheng wan cheng gong zuo xu yao shi jian bi jiao chang de shi hou ), ni hui fa xian dang bu shi yong lin jie qu shi , liang ge jin cheng “ tong shi ” chu xian dui gong gong nei cun qu de fang wen , shu zu mei you an zhao ni de yu ding fang shi jin xing chu shi hua ( li xiang de qing kuang shi shu zu xian bei chu shi hua wei 1, ran hou zai shi 2, ke shi ji qing kuang , ni ke neng kan dao zai di yi ge xian cheng dui shu zu chu shi hua shi , di er ge xian cheng qiang zhan le CPU, suo yi , da liang de shu zu cheng yuan bei gai xie cheng le 2), dang shi yong lin jie qu shi , ni hui fa xian shu zu an zhao wo men she ding de si lu xian bei chu shi hua wei 1, ran hou zai chu shi hua wei 2。
   rang wo men lai kan kan zai shi yong lin jie qu de qing kuang xia xi tong shi ru he tiao du zhe liang ge xian cheng de , dang di yi ge xian cheng chuang jian zhi hou , ta cheng wei ke tiao du zhuang tai , zhi yu xi tong mu qian shi fou fen pei CPU shi jian pian gei ta , wo men bu zhi dao , zhe yao kan xi tong zhong qi ta jin cheng de qing kuang , ran hou di er ge xian cheng chuang jian , bing qie ye cheng wei ke tiao du zhuang tai , dang xi tong fa xian ke yi tiao du zhe liang ge xian cheng de shi hou ( ye xu zai di yi ge xian cheng chuang jian zhi hou , ta jiu yi jing bei tiao du le ), xi tong tiao du yi ge xian cheng , wo men zhe li zan qie jia she tiao du de shi di yi ge xian cheng , xian cheng zhi xing EnterCriticalSection(cs) geng xin CRITICAL_SECTION(DLEPHI zhong jiang ta ding yi wei TRTLCriticalSection de ji lu ) de cheng yuan bian liang , yi zhi ming tiao yong xian cheng yi bei fu yu fang wen quan bing li ji fan hui , shi gai xian cheng neng gou ji xu yun xing , ran hou zai yi ding shi jian zhi hou , xian cheng 2 qiang zhan le CPU, ran hou zhi xing EnterCriticalSection(cs), shua xin CRITICAL_SECTION de cheng yuan bian lian , xi tong fa xian yi ge xian cheng yi jing bei fu yu le zi yuan de fang wen quan , zhe shi , xi tong jiang tiao yong xian cheng ( wo men zhe li de xian cheng 2) zhi yu deng dai zhuang tai 。 zhe zhong qing kuang shi ji hao de , yin wei deng dai de xian cheng bu hui lang fei ren he CPU shi jian 。 xi tong neng gou ji zhu gai xian cheng xiang yao fang wen gai zi yuan bing qie zi dong geng xin CRITICAL_SECTION de cheng yuan bian liang , zhi dao xian cheng 1 chong xin bei tiao du , bing zhi xing le LeaveCriticalSection han shu , zhe shi xi tong bian jiang xian cheng 2 zhi wei ke tiao du zhuang tai , ran hou zai he shi de shi jian , xian cheng 2 bei tiao du , zai ci wan cheng dui shu zu chu shi hua de gong zuo 。
  shi yong lin jie qu shi yao zhu yi de nei rong
  1、EnterCriticalSection he LeaveCriticalSection yao pei dui chu xian , ru guo ni zhi tiao yong EnterCriticalSection er wang ji shi yong LeaveCriticalSection, na me jie guo jiang shi ke pa de , zhe yi wei zhe qi ta xu yao fang wen bei bao hu zi yuan de xian cheng jiang yong yuan de deng dai xia qu , zhi dao zui zhong chao shi , chan sheng yi ge yi chang tiao jian 。 chao shi de shi jian bei ding yi zai zhu ce biao de HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager zhong , mo ren da yue shi 30 tian de shi jian 。
  2、CRITICAL_SECTION jie gou zhong de cheng yuan ying gai zai ren he xian cheng shi tu fang wen bei bao hu de zi yuan zhi qian chu shi hua 。 ni yao tiao yong InitializeCriticalSection lai wan cheng ci cao zuo 。 ru guo yi ge xian cheng shi tu jin ru wei chu shi hua de CRITICAL_SECTION, na me jie guo jiang shi wu fa yu liao de 。
  3、 dang zhi dao jin cheng de xian cheng bu zai shi tu fang wen gong xiang zi yuan shi , yong DeleteCriticalSection han shu qing chu CRITICAL_SECTION jie gou
  ji ge you yong de ji qiao
  1)、 mei ge xu bao hu de gong xiang zi yuan shi yong yi ge dan du de CRITICAL_SECTION bian liang , li ru xian cheng 1 he xian cheng 2 fang wen yi ge zi yuan A, er xian cheng 1 he xian cheng 3 fang wen ling yi ge zi yuan B, na zui hao dou zi yuan A、B dou shi yong yi ge dan du de CRITICAL_SECTION bian liang , ru guo shi yong tong yi ge CRITICAL_SECTION bian liang , na me jia ru xian cheng 1 xian bei tiao du le , xian cheng 2、3 ze zhi you deng dai xian cheng 1 wan cheng dui A、B de shi yong hou cai you ji hui yun xing 。 ru guo shi yong dan du de CRITICAL_SECTION bian liang , ze zai xian cheng 1 shi yong wan A zhi hou , xian cheng 2 ji ke xun su cheng wei bei tiao du zhuang tai 。
  2)、 dang yao fang wen duo ge bei bao hu zi yuan shi , ru guo ni shi yong de bu tong de CRITICAL_SECTION bian liang , na me yao zhu yi ta men de shun xu , li ru xian cheng 1 xian hou tiao yong EnterCriticalSection(cs1);EnterCriticalSection(cs2), er you ling wai yi ge xian cheng ze shi yong ling wai de shun xu EnterCriticalSection(cs2),EnterCriticalSection(cs1), na me jiang you ke neng chu xian si suo de qing kuang , xian cheng 1 bei tiao du , huo de bei cs1 bao hu de zi yuan A de shi yong quan , ran hou xian cheng 2 bei tiao du , huo de le bei cs2 bao hu de zi yuan B de shi yong quan , na me ci shi , wu lun shi xian cheng 1, huan shi xian cheng 2, dou jiang yin wei dui fang er yi zhi deng dai xia qu 。
  3)、 bu yao zai lin jie qu nei chang shi jian zhi xing na xie bu xu yao shi yong bao hu zi yuan de dai ma 。 ru guo chang shi jian zhi xing na xie bu bi yao bao hu de dai ma , qi ta de xi wang fang wen bao hu zi yuan de xian cheng jiang chang shi jian de deng dai xia qu 。
  xian cheng yu nei gai dui xiang de tong bu
   yong hu fang shi tong bu de you dian shi ta de tong bu su du fei chang kuai 。 sui ran yong hu fang shi de xian cheng tong bu ji zhi ju you su du kuai de you dian , dan qi ju xian xing ye shi ming xian de 。 li ru , hu suo han shu jia zu zhi neng zai dan zhi shang yun xing , gen ben wu fa shi xian cheng jin ru deng dai zhuang tai 。 wo men shi yong lin jie qu de fang shi ke yi shi de xian cheng jin ru deng dai zhuang tai , dan shi zhi neng yong zhe xie dai ma duan dui dan ge jin cheng zhong de xian cheng shi shi tong bu 。 yin wei zai deng dai jin lin jie qu shi ni wu fa fang bian de she ding chao shi zhi , suo yi you ke neng chu xian si suo de zhuang tai 。
   shang mian wo yi zhi qiang tiao le yi ge gai nian , jiu shi deng dai zhuang tai , zhe shi hen chong yao de , yin wei deng dai zhuang tai de xian cheng jiang bu shi yong CPU zi yuan 。
   nei gai dui xiang ji zhi de shi ying xing yuan yuan you yu yong hu fang shi ji zhi 。 shi ji shang , nei gai dui xiang ji zhi de wei yi bu zu zhi chu shi ta de su du bi jiao man 。《WINDOWS gai xin bian cheng 》 yi shu zhong shuo ” zhe ge zhuan huan xu yao hen da de dai jia : wang fan yi ci xu yao zhan yong x86 ping tai shang de da yue 1000 ge CPU zhou qi , dang ran , zhe huan bu bao kuo zhi xing nei gai fang shi dai ma , ji shi xian xian cheng tiao yong de han shu de dai ma suo xu de shi jian 。“, wo mei you ce shi guo , bu zhi dao zhe 1000 ge CPU zhou qi de shuo fa shi fou zhun que , dan ke yi ken ding nei gai dui xiang ji zhi jiang bi yong hu mo shi xia de tong bu yao man 。
   Windows de nei gai dui xiang , bao kuo jin cheng , xian cheng he zuo ye deng 。 ke yi jiang suo you zhe xie nei gai dui xiang yong yu tong bu mu de 。 dui yu xian cheng tong bu lai shuo , zhe xie nei gai dui xiang zhong de mei zhong dui xiang dou ke yi shuo shi chu yu yi tong zhi huo wei tong zhi de zhuang tai zhi zhong 。 li ru , jin cheng nei gai dui xiang zong shi zai wei tong zhi zhuang tai zhong chuang jian de 。 dang jin cheng zhong zhi yun xing shi , cao zuo xi tong zi dong shi gai jin cheng de nei gai dui xiang chu yu yi tong zhi zhuang tai 。 yi dan jin cheng nei gai dui xiang de dao tong zhi , ta jiang yong yuan bao chi zhe zhong zhuang tai , ta de zhuang tai yong yuan bu hui gai wei wei tong zhi zhuang tai 。 dang jin cheng zheng zai yun xing de shi hou , jin cheng nei gai dui xiang chu yu wei tong zhi zhuang tai , dang jin cheng zhong zhi yun xing de shi hou , ta jiu bian wei yi tong zhi zhuang tai 。
   shi ji shang , xian cheng nei gai dui xiang ye zun xun tong yang de gui ze 。 yu jin cheng nei gai dui xiang yi yang , xian cheng nei gai dui xiang ye ke yi chu yu yi tong zhi zhuang tai huo wei tong zhi zhuang tai 。
   xia mian de nei gai dui xiang ke yi chu yu yi tong zhi zhuang tai huo wei tong zhi zhuang tai : jin cheng 、 wen jian xiu gai tong zhi xian cheng 、 shi jian 、 zuo ye 、 ke deng dai ding shi qi 、 wen jian 、 xin biao 、 kong zhi tai shu ru 、 hu chi dui xiang
   xian cheng ke yi shi zi ji jin ru deng dai zhuang tai , zhi dao yi ge dui xiang bian wei yi tong zhi zhuang tai 。 zhu yi , yong yu kong zhi mei ge dui xiang de yi tong zhi / wei tong zhi zhuang tai de gui ze yao gen ju dui xiang de lei xing er ding 。
  deng dai han shu
   zui chang yong de mo guo yu WaitForSingleObject
   DWORD WaitForSingleObject(HANDLE hObject,DWORD dwMillseconds);
   dang xian cheng tiao yong gai han shu shi , di yi ge shen shu biao shi yi ge neng gou zhi chi bei tong zhi / wei tong zhi de nei gai dui xiang 。 di er ge shen shu yuan xu gai xian cheng zhi ming wei le deng dai gai dui xiang bian wei yi tong zhi zhuang tai , ta jiang deng dai duo chang shi jian 。WaitForSingleObject de fan hui zhi neng gou zhi ming tiao yong xian cheng wei shen me zai ci bian wei ke tiao du zhuang tai 。 ru guo xian cheng deng dai de dui xiang bian wei yi tong zhi zhuang tai , na me fan hui zhi shi WAIT_OBJECT_0。 ru guo she zhi de chao shi yi jing dao qi , ze fan hui zhi shi WAIT_TIMEOUT。 ru guo jiang yi ge cuo wu de zhi ( ru yi ge wu xiao ju bing ) chuan di gei WaitForSingleObject, na me fan hui zhi jiang shi WAIT_FAILED。
  shi jian dui xiang
   zai suo you de nei gai dui xiang zhong , shi jian nei gai dui xiang shi ge zui ji ben de dui xiang 。 ta men bao han yi ge shi yong ji shu ( yu suo you nei gai dui xiang yi yang ), yi ge yong yu zhi ming gai shi jian shi ge zi dong chong zhi de shi jian huan shi yi ge ren gong chong zhi de shi jian de bu er zhi , ling yi ge yong yu zhi ming gai shi jian chu yu yi tong zhi zhuang tai huan shi wei tong zhi zhuang tai de bu er zhi 。
   shi jian neng gou tong zhi yi ge cao zuo yi jing wan cheng 。 you liang zhong bu tong lei xing de shi jian dui xiang 。 yi zhong shi ren gong chong zhi de shi jian , ling yi zhong shi zi dong chong zhi de shi jian 。 dang ren gong chong zhi de shi jian de dao tong zhi shi , deng dai gai shi jian de suo you xian cheng yun bian wei ke tiao du xian cheng 。 dang yi ge zi dong chong zhi de shi jian de dao tong zhi shi , deng dai gai shi jian de xian cheng zhong zhi you yi ge xian cheng bian wei ke tiao du xian cheng 。
   dang yi ge xian cheng zhi xing chu shi hua cao zuo , ran hou tong zhi ling yi ge xian cheng zhi xing sheng yu de cao zuo shi , shi jian shi yong de zui duo 。 shi jian chu shi hua wei wei tong zhi zhuang tai , ran hou , dang gai xian cheng wan cheng ta de chu shi hua cao zuo hou , ta jiu jiang shi jian she zhi wei yi tong zhi zhuang tai 。 zhe shi , yi zhi zai deng dai gai shi jian de ling yi ge xian cheng fa xian gai shi jian yi jing de dao tong zhi , yin ci ta jiu bian cheng ke tiao du xian cheng 。 zhe di er ge xian cheng zhi dao di yi ge xian cheng yi jing wan cheng le ta de cao zuo 。
   HANDLE CreateEvent(PSECURITY_ATTRIBUTS psa,
   bool fManualRest,
   bool fInitialState,
   PCTSTR pszname);
   di yi ge shen shu yong lai zhi ding an quan shu xing , tong chang wo men yong null, zui hou yi ge shen shu yong lai zhi ding yi ge ming zi 。fManualRest, shen shu shi ge bu er zhi , ta neng gou gao su xi tong shi chuang jian yi ge ren gong chong zhi de shi jian huan shi chuang jian yi ge zi dong chong zhi de shi jian (FALSE)。fInitialState, shen shu yong yu zhi ming gai shi jian shi yao chu shi hua wei yi tong zhi zhuang tai (TRUE) huan shi wei tong zhi zhuang tai (FALSE)。 dang xi tong chuang jian shi jian dui xiang hou ,createEvent jiu jiang yu jin cheng xiang guan de ju bing fan hui gei shi jian dui xiang 。 qi ta jin cheng zhong de xian cheng ke yi huo de dui gai dui xiang de fang wen quan , fang fa shi shi yong zai pszName shen shu zhong chuan di de xiang tong zhi , shi yong ji cheng xing , shi yong DuplicateHandle han shu deng lai tiao yong CreateEvent, huo zhe tiao yong OpenEvent, zai pszName shu zhong she ding yi ge yu tiao yong CreateEvent shi she ding de ming zi xiang pi pei de ming zi 。
   yi dan shi jian yi jing chuang jian , jiu ke yi zhi jie kong zhi ta de zhuang tai 。 dang tiao yong SetEvent shi , ke yi jiang shi jian gai wei yi tong zhi zhuang tai : dang tiao yong ResetEvent han shu shi , ke yi jiang gai shi jian gai wei wei tong zhi zhuang tai 。
   zi dong chong zhi de shi jian yu ren gong chong zhi shi jian de qu bie zai yu , zi dong chong zhi shi jian zai xian cheng cheng gong di deng dai dao gai dui xiang shi , zi dong chong zhi de shi jian jiu hui zi dong chong zhi dao wei tong zhi zhuang tai 。 tong chang mei you bi yao wei zi dong chong zhi de shi jian tiao yong ResetEvent han shu , yin wei xi tong hui zi dong dui shi jian jin xing chong zhi
  yi ge li zi :
WIN32下DELPHI中的多线程【同步1】(四)
WIN32下DELPHI中的多线程【同步1】(四)
...{
WIN32下DELPHI中的多线程【同步1】(四)
zuo zhe :wudi_1982
WIN32下DELPHI中的多线程【同步1】(四)
lian xi fang shi :wudi_1982@hotmail.com
WIN32下DELPHI中的多线程【同步1】(四)
ben dai ma zhi tie chu le yi xie bi jiao guan jian de bu fen
WIN32下DELPHI中的多线程【同步1】(四)
zhuan zai qing zhu ming chu chu
WIN32下DELPHI中的多线程【同步1】(四)
}
WIN32下DELPHI中的多线程【同步1】(四)

WIN32下DELPHI中的多线程【同步1】(四)
// li yong shi jian dui xiang yan shi tong bu de TThread pai sheng lei
WIN32下DELPHI中的多线程【同步1】(四)
TEventThread=class(TThread)
WIN32下DELPHI中的多线程【同步1】(四)
private
WIN32下DELPHI中的多线程【同步1】(四)
CurCount : integer;// dang qian ji shu
WIN32下DELPHI中的多线程【同步1】(四)
Flabel : TLabel;// xian shi dang qian ji shu de Tlabel zu jian
WIN32下DELPHI中的多线程【同步1】(四)
procedure GetRestult;
WIN32下DELPHI中的多线程【同步1】(四)
protected
WIN32下DELPHI中的多线程【同步1】(四)
procedure Execute;override;
WIN32下DELPHI中的多线程【同步1】(四)
public
WIN32下DELPHI中的多线程【同步1】(四)
constructor Create(Alabel : TLabel);
WIN32下DELPHI中的多线程【同步1】(四)
end;
WIN32下DELPHI中的多线程【同步1】(四)

WIN32下DELPHI中的多线程【同步1】(四)
var
WIN32下DELPHI中的多线程【同步1】(四)
EventHandle : THandle;// shi jian dui xiang de ju bing
WIN32下DELPHI中的多线程【同步1】(四)

WIN32下DELPHI中的多线程【同步1】(四)
//TEventThread de shi xian dai ma
WIN32下DELPHI中的多线程【同步1】(四)

WIN32下DELPHI中的多线程【同步1】(四)
WIN32下DELPHI中的多线程【同步1】(四)
...{ TEventThread }
WIN32下DELPHI中的多线程【同步1】(四)

WIN32下DELPHI中的多线程【同步1】(四)
constructor TEventThread.Create(Alabel: TLabel);
WIN32下DELPHI中的多线程【同步1】(四)
begin
WIN32下DELPHI中的多线程【同步1】(四)
Flabel := Alabel;
WIN32下DELPHI中的多线程【同步1】(四)
inherited Create(False);
WIN32下DELPHI中的多线程【同步1】(四)
end;
WIN32下DELPHI中的多线程【同步1】(四)

WIN32下DELPHI中的多线程【同步1】(四)
procedure TEventThread.Execute;
WIN32下DELPHI中的多线程【同步1】(四)
var
WIN32下DELPHI中的多线程【同步1】(四)
i : integer;
WIN32下DELPHI中的多线程【同步1】(四)
begin
WIN32下DELPHI中的多线程【同步1】(四)
inherited;
WIN32下DELPHI中的多线程【同步1】(四)
CurCount := 0;
WIN32下DELPHI中的多线程【同步1】(四)
for i := 0 to 10000 do
WIN32下DELPHI中的多线程【同步1】(四)
begin
WIN32下DELPHI中的多线程【同步1】(四)
case WaitForSingleObject(EventHandle,5000) of
WIN32下DELPHI中的多线程【同步1】(四)
WAIT_OBJECT_0 : begin// ru guo deng dai dao shi jian dui xiang , ze jiang dang qian ji shu jia 1, bing qie xian shi zai zhi ding label shang
WIN32下DELPHI中的多线程【同步1】(四)
Inc(CurCount);
WIN32下DELPHI中的多线程【同步1】(四)
Synchronize(GetRestult);
WIN32下DELPHI中的多线程【同步1】(四)
Sleep(0);
WIN32下DELPHI中的多线程【同步1】(四)
// guan yu sleep,switchtoThread de shi yong qian mian yi jing shuo le
WIN32下DELPHI中的多线程【同步1】(四)
// SwitchToThread
WIN32下DELPHI中的多线程【同步1】(四)
//Application.ProcessMessages;
WIN32下DELPHI中的多线程【同步1】(四)
end;//WAIT_OBJECT_0
WIN32下DELPHI中的多线程【同步1】(四)
WAIT_TIMEOUT : begin// chao shi ze zi dong chong zhi dang qian ji shu
WIN32下DELPHI中的多线程【同步1】(四)
CurCount := 0;
WIN32下DELPHI中的多线程【同步1】(四)
Synchronize(GetRestult);
WIN32下DELPHI中的多线程【同步1】(四)
SwitchToThread;
WIN32下DELPHI中的多线程【同步1】(四)
end;
WIN32下DELPHI中的多线程【同步1】(四)
end;
WIN32下DELPHI中的多线程【同步1】(四)
end;
WIN32下DELPHI中的多线程【同步1】(四)
end;
WIN32下DELPHI中的多线程【同步1】(四)

WIN32下DELPHI中的多线程【同步1】(四)
procedure TEventThread.GetRestult;
WIN32下DELPHI中的多线程【同步1】(四)
begin
WIN32下DELPHI中的多线程【同步1】(四)
Flabel.Caption := IntToStr(CurCount);
WIN32下DELPHI中的多线程【同步1】(四)
end;
WIN32下DELPHI中的多线程【同步1】(四)

WIN32下DELPHI中的多线程【同步1】(四)
// chuang ti dan yuan zhong ce shi TEventThread de yi xie dai ma
WIN32下DELPHI中的多线程【同步1】(四)
procedure TForm1.CreateTClick(Sender: TObject);
WIN32下DELPHI中的多线程【同步1】(四)
begin
WIN32下DELPHI中的多线程【同步1】(四)
// zhe li chuang jian le TEventThread xian cheng lei de liang ge shi li , mu de shi geng hao de yan shi zi dong chong zhi he shou dong chong zhi de qu bie
WIN32下DELPHI中的多线程【同步1】(四)
TEventThread.Create(labEvent);
WIN32下DELPHI中的多线程【同步1】(四)
TEventThread.Create(labEvent2);
WIN32下DELPHI中的多线程【同步1】(四)
end;
WIN32下DELPHI中的多线程【同步1】(四)

WIN32下DELPHI中的多线程【同步1】(四)
procedure TForm1.CreateEClick(Sender: TObject);
WIN32下DELPHI中的多线程【同步1】(四)
begin
WIN32下DELPHI中的多线程【同步1】(四)
// sheng cheng yi ge shi jian dui xiang , shi jian dui xiang de chong zhi fang shi yi ji chu shi hua zhuang tai tong guo liang ge checkBox lai jue ding
WIN32下DELPHI中的多线程【同步1】(四)
EventHandle := CreateEvent(nil,ckbxAutoReset.Checked, ckbxInitEventState.Checked,pchar('MyEvent'));
WIN32下DELPHI中的多线程【同步1】(四)
end;
WIN32下DELPHI中的多线程【同步1】(四)

WIN32下DELPHI中的多线程【同步1】(四)
procedure TForm1.SetEClick(Sender: TObject);
WIN32下DELPHI中的多线程【同步1】(四)
begin
WIN32下DELPHI中的多线程【同步1】(四)
// tong zhi
WIN32下DELPHI中的多线程【同步1】(四)
SetEvent(EventHandle);
WIN32下DELPHI中的多线程【同步1】(四)
end;
WIN32下DELPHI中的多线程【同步1】(四)

WIN32下DELPHI中的多线程【同步1】(四)
procedure TForm1.ResetEClick(Sender: TObject);
WIN32下DELPHI中的多线程【同步1】(四)
begin
WIN32下DELPHI中的多线程【同步1】(四)
// wei tong zhi
WIN32下DELPHI中的多线程【同步1】(四)
ResetEvent(EventHandle);
WIN32下DELPHI中的多线程【同步1】(四)
end;
WIN32下DELPHI中的多线程【同步1】(四)

WIN32下DELPHI中的多线程【同步1】(四)
procedure TForm1.closeClick(Sender: TObject);
WIN32下DELPHI中的多线程【同步1】(四)
begin
WIN32下DELPHI中的多线程【同步1】(四)
// zai ni que ding bu xu yao ci shi jian dui xiang de shi hou , ji de shi fang zi yuan
WIN32下DELPHI中的多线程【同步1】(四)
CloseHandle(EventHandle)
WIN32下DELPHI中的多线程【同步1】(四)
end;
WIN32下DELPHI中的多线程【同步1】(四)

WIN32下DELPHI中的多线程【同步1】(四)

WIN32下DELPHI中的多线程【同步1】(四)

  li yong shi jian dui xiang yan shi tong bu de cheng xu jie mian
WIN32下DELPHI中的多线程【同步1】(四)

   zheng li shang shu dai ma , ran hou fen bie yong bu tong de pei zhi bu tong shun xu de dian ji an niu , ke yi rang ni dui shi jian dui xiang de shi yong jia shen le jie 。
   nei gai fang shi de tong bu huan you hen duo zhong , dan yuan li ji ben dou yi yang , hou xu wen zhang dui jin ke neng de yi ci ju li lie ju 。
  shen kao wen xian :《WINDOWS gai xin bian cheng 》
   zhu : zhuan zai qing zhu ming chu chu , xie xie【原文】【汉音对照
 
 
 
 
 
 
 
 
 
日版宠物情人插曲《Winding Road》歌词

日版宠物情人2017的插曲,很带节奏感,日语的,女生唱的。 最后听见是在第8集的时候女主手割伤了,然后男主用嘴帮她吸了一下,插曲就出来了。 歌手:Def...

兄弟共妻,我成了他们夜里的美食

老钟家的两个儿子很特别,就是跟其他的人不太一样,魔一般的执着。兄弟俩都到了要结婚的年龄了,不管自家老爹怎么磨破嘴皮子,兄弟俩说不娶就不娶,老父母为兄弟两操碎了心...

如何磨出破洞牛仔裤?牛仔裤怎么剪破洞?

把牛仔裤磨出有线的破洞 1、具体工具就是磨脚石,下面垫一个硬物,然后用磨脚石一直磨一直磨,到把那块磨薄了,用手撕开就好了。出来的洞啊很自然的。需要猫须的话调几...

我就是扫描下图得到了敬业福和爱国福

先来看下敬业福和爱国福 今年春节,支付宝再次推出了“五福红包”活动,表示要“把欠大家的敬业福都还给大家”。 今天该活动正式启动,和去年一样,需要收集“五福”...

冰箱异味产生的原因和臭味去除的方法

有时候我们打开冰箱就会闻到一股异味,冰箱里的这种异味是因为一些物质发出的气味的混合体,闻起来让人恶心。 产生这些异味的主要原因有以下几点。 1、很多人有这种习...

 
 
xian cheng de tong bu zai shi yong de shi hou , duo xian cheng zui rang ren tou teng de ye xu jiu shi tong bu le 。 ru guo ni de xian cheng zhi shi wan cheng yi jian bing bu xu yao fang wen xian cheng dui xiang wai bu zi yuan de gong zuo , zai zhe zhong qing kuang xia , xian cheng hu xiang zhi jian bu xu yao jin xing tong xin , ci shi Windows de yun xing xing neng zui hao 。 dan shi , xian cheng hen shao neng gou zai suo you de shi jian dou du li di jin xing cao zuo 。 tong chang qing kuang xia , yao sheng cheng yi xie xian cheng lai chu li mou ge ren wu 。 dang zhe ge ren wu wan cheng shi , ling yi ge xian cheng bi xu le jie zhe ge qing kuang 。 xi tong zhong de suo you xian cheng dou bi xu yong you dui ge zhong xi tong zi yuan de fang wen quan , zhe xie zi yuan bao kuo nei cun dui zhan , wen jian , chuang kou he xu duo qi ta zi yuan 。 ru guo yi ge xian cheng xu yao du zhan dui zi yuan de fang wen quan , na me qi ta xian cheng jiu wu fa wan cheng ta men de gong zuo 。 fan guo lai shuo , ye bu neng rang ren he yi ge xian cheng zai ren he shi jian dou neng fang wen suo you de zi yuan 。 ru guo zai yi ge xian cheng cong nei cun kuai zhong du qu shu ju shi , ling yi ge xian cheng que xiang yao jiang shu ju xie ru tong yi ge nei cun kuai , na me zhe jiu xiang ni zai du yi ben shu shi ling yi ge ren que zai xiu gai shu zhong de nei rong yi yang 。 zhe yang , shu zhong de nei rong jiu hui bei gao de luan qi ba zao , jie guo shen me ye kan bu qing chu 。 xian cheng xu yao zai xia mian liang zhong qing kuang xia hu xiang jin xing tong xin : • dang you duo ge xian cheng fang wen gong xiang zi yuan er bu shi zi yuan bei po huai shi 。 • dang yi ge xian cheng xu yao jiang mou ge ren wu yi jing wan cheng de qing kuang tong zhi ling wai yi ge huo duo ge xian cheng shi 。 xian cheng de tong bu bao kuo xu duo fang mian de nei rong ,Windows ti gong le xu duo fang fa , ke yi fei chang rong yi di shi xian xian cheng de tong bu 。 dan shi , yao xiang sui shi le jie yi lian chuan de xian cheng xiang yao zuo shen me , na shi fei chang kun nan de 。 wo men de tou nao de gong zuo bu shi yi bu de , wo men xi wang yi yi zhong you xu de fang shi lai si kao xu duo shi qing , mei ci qian jin yi bu 。 bu guo duo xian cheng huan jing bu shi zhe yang yun xing de 。 ni ji hu wu fa wan quan zhi dao mu biao xi tong zhong cun zai duo shao xian cheng , ye bu zhi dao ta men chu zai shen me zhuang tai xia , geng bu zhi dao ta men yao gan shen me 。 yong hu fang shi xia de xian cheng tong bu 1、 hu suo han shu    zai MSDN guan yu tong bu han shu de bang zhu wen dang zhong , ni hui kan dao da liang de hu suo han shu 。 ta men da duo yi Interlocked**** de ming zi cun zai 。 hu suo han shu yun xing zai yong hu mo shi 。 ta neng bao zheng dang yi ge xian cheng fang wen yi ge bian liang shi , qi ta xian cheng wu fa fang wen ci bian liang , yi que bao bian liang zhi de wei yi xing 。 zhe zhong fang wen fang shi bei cheng wei yuan zi fang wen 。 chang yong de hu suo han shu ji qi gong neng jian ru xia lie biao : han shu shen shu he gong neng InterlockedIncrement shen shu wei PLONG lei xing 。 ci han shu shi yi ge LONG bian liang zeng 1 InterlockedDecrement shen shu wei PLONG lei xing 。 ci han shu shi yi ge LONG bian liang jian 1 InterlockedExchangeAdd shen shu 1 wei PLONG lei xing , shen shu 2 wei LONG lei xing 。 ci han shu jiang shen shu 2 fu gei shen shu 1 zhi xiang de zhi InterlockedExchange shen shu 1 wei PLONG lei xing , shen shu 2 wei LONG lei xing 。 ci han shu jiang shen shu 2 de zhi fu gei shen shu 1 zhi xiang de zhi InterlockedExchangePointer shen shu wei PVOID* lei xing , shen shu 2 wei PVOID lei xing 。 ci han shu gong neng tong shang 。   yong InterlockedExchangeAdd lai shuo ming , ta jie shou yi ge chang zheng xing bian liang de di zhi , ran hou jiang shen shu 2 de shu zhi jia dao shen shu 1 zhi ding de chang zheng xing shu ju shang 。 wo men qian bian yi jing shuo le , ta neng bao zheng dang yi ge xian cheng fang wen ci chang zheng xing bian liang shi , qi ta xian cheng wu fa fang wen ci bian liang , na me ta shi ru he shi xian de ne ? da an qu jue yu yun xing de shi he zhong CPU ping tai 。 dui yu x86 jia zu de CPU lai shuo , hu suo han shu hui dui zong xian fa chu yi ge ying jian xin hao , fang zhi ling yi ge CPU fang wen tong yi ge nei cun di zhi 。 zai Alpha ping tai shang , hu suo han shu neng gou zhi xing xia lie cao zuo 1) da kai C P U zhong de yi ge te shu de wei biao zhi , bing zhu ming bei fang wen de nei cun di zhi 。 2) jiang nei cun de zhi du ru yi ge ji cun qi 。 3) xiu gai gai ji cun qi 。 4) ru guo C P U zhong de te shu wei biao zhi shi guan bi de , ze zhuan ru di er bu 。 fou ze , te shu wei biao zhi reng ran shi da kai de , ji cun qi de zhi chong xin cun ru nei cun 。 hu suo han shu gong zuo yu yong hu mo shi zhi xia , suo yi ta de su du shi fei chang kuai dian de 。 you li jiu you bi , hu suo han shu zui da de que dian mo guo yu shi yong fan wei de xia ai xing le , ta geng duo de zhi shi dui dan ge bian liang de bao hu 。 2、 lin jie qu ye you de di fang jiao ta guan jian dai ma duan 。 lin jie qu zhi yi ge xiao dai ma duan , zai dai ma neng gou zhi xing qian , ta bi xu du zhan dui mou xie gong xiang zi yuan de fang wen quan 。 zhe shi rang ruo gan xing dai ma neng gou “ yi yuan zi cao zuo fang shi ” lai shi yong zi yuan de yi zhong fang fa 。 suo wei yuan zi cao zuo fang shi , shi zhi gai dai ma zhi dao mei you bie de xian cheng yao fang wen gai zi yuan 。 jian dan de shuo , jiu shi yi ci zhi neng you yi ge xian cheng lai zhi xing de yi duan dai ma 。 xian lai kan yi duan li zi , zai li zi zhong , xian cheng wan cheng dui yi ge shu zu chu shi hua de gong zuo , mu biao shi zai dang qian de shu zhi shang jia 1,TThread dui xiang zhong huan ding yi le yi ge FUseCritical de bian liang , ta yong lai jue ding xian cheng zai zhi xing shi shi fou yao shi yong lin jie qu de fang shi 。 [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif[/img][/url][url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif[/img][/url]...{ [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] zuo zhe :wudi_1982 [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] lian xi fang shi :wudi_1982@hotmail.com [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] ben dai ma wei yan shi dai ma , zhi tie chu le yi xie bi jiao chong yao de dai ma [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] zhuan zai qing zhu ming chu chu [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif[/img][/url]} [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]const [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] MaxArray = 1000;// gong gong nei cun qu yu de da xiao [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]// yan shi lin jie qu gong neng de xian cheng lei [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]type [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] TCriticalSectionThread= class(TThread) [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] private [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] FUseCritical : Boolean;// jue ding shi fou shi yong lin jie qu [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] procedure GetRestult; [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] protected [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] procedure Execute;override; [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] public [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] constructor Create(UseCritical : Boolean); [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] end; [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]end; [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url].... [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]var [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] PublicMem : array[0..MaxArray] of integer;// yi kuai gong gong qu yu [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] Cs : TRTLCriticalSection;// miao shu lin jie qu xin xi de shu ju jie gou [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] shi xian dai ma ru xia : [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif[/img][/url][url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif[/img][/url]...{ TCriticalSectionThread } [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]constructor TCriticalSectionThread.Create(UseCritical: Boolean); [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]begin [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] // gou zao han shu zhong jie shou shi fou shi yong lin jie qu de shen shu [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] FUseCritical := UseCritical; [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] inherited Create(false); [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]end; [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]procedure TCriticalSectionThread.Execute; [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]var [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] i : integer; [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]begin [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] inherited; [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] // yun xing wan bi hou zi dong shi fang zi yuan [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] FreeOnTerminate := True; [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] // ru guo shi yong le lin jie qu , ze jin ru lin jie qu [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] if FUseCritical then [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] EnterCriticalSection(cs); [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] // dui shu zu chu shi hua [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] for i := 0 to MaxArray do [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] inc(PublicMem[i]); [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] Synchronize(GetRestult); [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] // li kai [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] if FUseCritical then [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] LeaveCriticalSection(Cs); [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]end; [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]procedure TCriticalSectionThread.GetRestult; [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]var [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] i : integer; [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]begin [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] // jiang jie guo xian shi zai Form1.listbox1 zhong [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] for i := 0 to MaxArray do [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] Form1.ListBox1.Items.Add(inttostr(PublicMem[i])); [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]end; [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]// tiao yong zhe ge xian cheng lei lai yan shi lin jie qu gong neng de dai ma [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]procedure TForm1.Button3Click(Sender: TObject); [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]begin [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] // jiang gong gong nei cun qu yu tian chong wei 0 [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] FillMemory(@PublicMem,sizeof(PublicMem),0); [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] ListBox1.Clear; [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] // yi ge CheckBox, yong lai jie shou shi fou shi yong lin jie qu fang shi de xin xi [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] if ckbxUsesC.Checked then [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] // ru guo shi yong lin jie qu , ze shou xian chu shi hua [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] InitializeCriticalSection(cs); [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] // tong shi sheng cheng liang ge xian cheng [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] TCriticalSectionThread.Create(ckbxUsesC.Checked); [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] TCriticalSectionThread.Create(ckbxUsesC.Checked); [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]end; [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]// hao de bian ma xi guan zhong , ni ying gai zai que ding xian cheng yi jing bu zai xu yao shi yong lin jie qu shi , yong DeleteCriticalSection(cs); qing chu zhe ge jie gou [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] zheng li shang mian dai ma , bing zhi xing , zai MaxArray ding yi bi jiao da de shi hou ( ye jiu shi yi ge xian cheng wan cheng gong zuo xu yao shi jian bi jiao chang de shi hou ), ni hui fa xian dang bu shi yong lin jie qu shi , liang ge jin cheng “ tong shi ” chu xian dui gong gong nei cun qu de fang wen , shu zu mei you an zhao ni de yu ding fang shi jin xing chu shi hua ( li xiang de qing kuang shi shu zu xian bei chu shi hua wei 1, ran hou zai shi 2, ke shi ji qing kuang , ni ke neng kan dao zai di yi ge xian cheng dui shu zu chu shi hua shi , di er ge xian cheng qiang zhan le CPU, suo yi , da liang de shu zu cheng yuan bei gai xie cheng le 2), dang shi yong lin jie qu shi , ni hui fa xian shu zu an zhao wo men she ding de si lu xian bei chu shi hua wei 1, ran hou zai chu shi hua wei 2。 rang wo men lai kan kan zai shi yong lin jie qu de qing kuang xia xi tong shi ru he tiao du zhe liang ge xian cheng de , dang di yi ge xian cheng chuang jian zhi hou , ta cheng wei ke tiao du zhuang tai , zhi yu xi tong mu qian shi fou fen pei CPU shi jian pian gei ta , wo men bu zhi dao , zhe yao kan xi tong zhong qi ta jin cheng de qing kuang , ran hou di er ge xian cheng chuang jian , bing qie ye cheng wei ke tiao du zhuang tai , dang xi tong fa xian ke yi tiao du zhe liang ge xian cheng de shi hou ( ye xu zai di yi ge xian cheng chuang jian zhi hou , ta jiu yi jing bei tiao du le ), xi tong tiao du yi ge xian cheng , wo men zhe li zan qie jia she tiao du de shi di yi ge xian cheng , xian cheng zhi xing EnterCriticalSection(cs) geng xin CRITICAL_SECTION(DLEPHI zhong jiang ta ding yi wei TRTLCriticalSection de ji lu ) de cheng yuan bian liang , yi zhi ming tiao yong xian cheng yi bei fu yu fang wen quan bing li ji fan hui , shi gai xian cheng neng gou ji xu yun xing , ran hou zai yi ding shi jian zhi hou , xian cheng 2 qiang zhan le CPU, ran hou zhi xing EnterCriticalSection(cs), shua xin CRITICAL_SECTION de cheng yuan bian lian , xi tong fa xian yi ge xian cheng yi jing bei fu yu le zi yuan de fang wen quan , zhe shi , xi tong jiang tiao yong xian cheng ( wo men zhe li de xian cheng 2) zhi yu deng dai zhuang tai 。 zhe zhong qing kuang shi ji hao de , yin wei deng dai de xian cheng bu hui lang fei ren he CPU shi jian 。 xi tong neng gou ji zhu gai xian cheng xiang yao fang wen gai zi yuan bing qie zi dong geng xin CRITICAL_SECTION de cheng yuan bian liang , zhi dao xian cheng 1 chong xin bei tiao du , bing zhi xing le LeaveCriticalSection han shu , zhe shi xi tong bian jiang xian cheng 2 zhi wei ke tiao du zhuang tai , ran hou zai he shi de shi jian , xian cheng 2 bei tiao du , zai ci wan cheng dui shu zu chu shi hua de gong zuo 。 shi yong lin jie qu shi yao zhu yi de nei rong 1、EnterCriticalSection he LeaveCriticalSection yao pei dui chu xian , ru guo ni zhi tiao yong EnterCriticalSection er wang ji shi yong LeaveCriticalSection, na me jie guo jiang shi ke pa de , zhe yi wei zhe qi ta xu yao fang wen bei bao hu zi yuan de xian cheng jiang yong yuan de deng dai xia qu , zhi dao zui zhong chao shi , chan sheng yi ge yi chang tiao jian 。 chao shi de shi jian bei ding yi zai zhu ce biao de HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager zhong , mo ren da yue shi 30 tian de shi jian 。 2、CRITICAL_SECTION jie gou zhong de cheng yuan ying gai zai ren he xian cheng shi tu fang wen bei bao hu de zi yuan zhi qian chu shi hua 。 ni yao tiao yong InitializeCriticalSection lai wan cheng ci cao zuo 。 ru guo yi ge xian cheng shi tu jin ru wei chu shi hua de CRITICAL_SECTION, na me jie guo jiang shi wu fa yu liao de 。 3、 dang zhi dao jin cheng de xian cheng bu zai shi tu fang wen gong xiang zi yuan shi , yong DeleteCriticalSection han shu qing chu CRITICAL_SECTION jie gou ji ge you yong de ji qiao 1)、 mei ge xu bao hu de gong xiang zi yuan shi yong yi ge dan du de CRITICAL_SECTION bian liang , li ru xian cheng 1 he xian cheng 2 fang wen yi ge zi yuan A, er xian cheng 1 he xian cheng 3 fang wen ling yi ge zi yuan B, na zui hao dou zi yuan A、B dou shi yong yi ge dan du de CRITICAL_SECTION bian liang , ru guo shi yong tong yi ge CRITICAL_SECTION bian liang , na me jia ru xian cheng 1 xian bei tiao du le , xian cheng 2、3 ze zhi you deng dai xian cheng 1 wan cheng dui A、B de shi yong hou cai you ji hui yun xing 。 ru guo shi yong dan du de CRITICAL_SECTION bian liang , ze zai xian cheng 1 shi yong wan A zhi hou , xian cheng 2 ji ke xun su cheng wei bei tiao du zhuang tai 。 2)、 dang yao fang wen duo ge bei bao hu zi yuan shi , ru guo ni shi yong de bu tong de CRITICAL_SECTION bian liang , na me yao zhu yi ta men de shun xu , li ru xian cheng 1 xian hou tiao yong EnterCriticalSection(cs1);EnterCriticalSection(cs2), er you ling wai yi ge xian cheng ze shi yong ling wai de shun xu EnterCriticalSection(cs2),EnterCriticalSection(cs1), na me jiang you ke neng chu xian si suo de qing kuang , xian cheng 1 bei tiao du , huo de bei cs1 bao hu de zi yuan A de shi yong quan , ran hou xian cheng 2 bei tiao du , huo de le bei cs2 bao hu de zi yuan B de shi yong quan , na me ci shi , wu lun shi xian cheng 1, huan shi xian cheng 2, dou jiang yin wei dui fang er yi zhi deng dai xia qu 。 3)、 bu yao zai lin jie qu nei chang shi jian zhi xing na xie bu xu yao shi yong bao hu zi yuan de dai ma 。 ru guo chang shi jian zhi xing na xie bu bi yao bao hu de dai ma , qi ta de xi wang fang wen bao hu zi yuan de xian cheng jiang chang shi jian de deng dai xia qu 。 xian cheng yu nei gai dui xiang de tong bu yong hu fang shi tong bu de you dian shi ta de tong bu su du fei chang kuai 。 sui ran yong hu fang shi de xian cheng tong bu ji zhi ju you su du kuai de you dian , dan qi ju xian xing ye shi ming xian de 。 li ru , hu suo han shu jia zu zhi neng zai dan zhi shang yun xing , gen ben wu fa shi xian cheng jin ru deng dai zhuang tai 。 wo men shi yong lin jie qu de fang shi ke yi shi de xian cheng jin ru deng dai zhuang tai , dan shi zhi neng yong zhe xie dai ma duan dui dan ge jin cheng zhong de xian cheng shi shi tong bu 。 yin wei zai deng dai jin lin jie qu shi ni wu fa fang bian de she ding chao shi zhi , suo yi you ke neng chu xian si suo de zhuang tai 。 shang mian wo yi zhi qiang tiao le yi ge gai nian , jiu shi deng dai zhuang tai , zhe shi hen chong yao de , yin wei deng dai zhuang tai de xian cheng jiang bu shi yong CPU zi yuan 。 nei gai dui xiang ji zhi de shi ying xing yuan yuan you yu yong hu fang shi ji zhi 。 shi ji shang , nei gai dui xiang ji zhi de wei yi bu zu zhi chu shi ta de su du bi jiao man 。《WINDOWS gai xin bian cheng 》 yi shu zhong shuo ” zhe ge zhuan huan xu yao hen da de dai jia : wang fan yi ci xu yao zhan yong x86 ping tai shang de da yue 1000 ge CPU zhou qi , dang ran , zhe huan bu bao kuo zhi xing nei gai fang shi dai ma , ji shi xian xian cheng tiao yong de han shu de dai ma suo xu de shi jian 。“, wo mei you ce shi guo , bu zhi dao zhe 1000 ge CPU zhou qi de shuo fa shi fou zhun que , dan ke yi ken ding nei gai dui xiang ji zhi jiang bi yong hu mo shi xia de tong bu yao man 。 Windows de nei gai dui xiang , bao kuo jin cheng , xian cheng he zuo ye deng 。 ke yi jiang suo you zhe xie nei gai dui xiang yong yu tong bu mu de 。 dui yu xian cheng tong bu lai shuo , zhe xie nei gai dui xiang zhong de mei zhong dui xiang dou ke yi shuo shi chu yu yi tong zhi huo wei tong zhi de zhuang tai zhi zhong 。 li ru , jin cheng nei gai dui xiang zong shi zai wei tong zhi zhuang tai zhong chuang jian de 。 dang jin cheng zhong zhi yun xing shi , cao zuo xi tong zi dong shi gai jin cheng de nei gai dui xiang chu yu yi tong zhi zhuang tai 。 yi dan jin cheng nei gai dui xiang de dao tong zhi , ta jiang yong yuan bao chi zhe zhong zhuang tai , ta de zhuang tai yong yuan bu hui gai wei wei tong zhi zhuang tai 。 dang jin cheng zheng zai yun xing de shi hou , jin cheng nei gai dui xiang chu yu wei tong zhi zhuang tai , dang jin cheng zhong zhi yun xing de shi hou , ta jiu bian wei yi tong zhi zhuang tai 。 shi ji shang , xian cheng nei gai dui xiang ye zun xun tong yang de gui ze 。 yu jin cheng nei gai dui xiang yi yang , xian cheng nei gai dui xiang ye ke yi chu yu yi tong zhi zhuang tai huo wei tong zhi zhuang tai 。 xia mian de nei gai dui xiang ke yi chu yu yi tong zhi zhuang tai huo wei tong zhi zhuang tai : jin cheng 、 wen jian xiu gai tong zhi xian cheng 、 shi jian 、 zuo ye 、 ke deng dai ding shi qi 、 wen jian 、 xin biao 、 kong zhi tai shu ru 、 hu chi dui xiang xian cheng ke yi shi zi ji jin ru deng dai zhuang tai , zhi dao yi ge dui xiang bian wei yi tong zhi zhuang tai 。 zhu yi , yong yu kong zhi mei ge dui xiang de yi tong zhi / wei tong zhi zhuang tai de gui ze yao gen ju dui xiang de lei xing er ding 。 deng dai han shu zui chang yong de mo guo yu WaitForSingleObject DWORD WaitForSingleObject(HANDLE hObject,DWORD dwMillseconds); dang xian cheng tiao yong gai han shu shi , di yi ge shen shu biao shi yi ge neng gou zhi chi bei tong zhi / wei tong zhi de nei gai dui xiang 。 di er ge shen shu yuan xu gai xian cheng zhi ming wei le deng dai gai dui xiang bian wei yi tong zhi zhuang tai , ta jiang deng dai duo chang shi jian 。WaitForSingleObject de fan hui zhi neng gou zhi ming tiao yong xian cheng wei shen me zai ci bian wei ke tiao du zhuang tai 。 ru guo xian cheng deng dai de dui xiang bian wei yi tong zhi zhuang tai , na me fan hui zhi shi WAIT_OBJECT_0。 ru guo she zhi de chao shi yi jing dao qi , ze fan hui zhi shi WAIT_TIMEOUT。 ru guo jiang yi ge cuo wu de zhi ( ru yi ge wu xiao ju bing ) chuan di gei WaitForSingleObject, na me fan hui zhi jiang shi WAIT_FAILED。 shi jian dui xiang zai suo you de nei gai dui xiang zhong , shi jian nei gai dui xiang shi ge zui ji ben de dui xiang 。 ta men bao han yi ge shi yong ji shu ( yu suo you nei gai dui xiang yi yang ), yi ge yong yu zhi ming gai shi jian shi ge zi dong chong zhi de shi jian huan shi yi ge ren gong chong zhi de shi jian de bu er zhi , ling yi ge yong yu zhi ming gai shi jian chu yu yi tong zhi zhuang tai huan shi wei tong zhi zhuang tai de bu er zhi 。 shi jian neng gou tong zhi yi ge cao zuo yi jing wan cheng 。 you liang zhong bu tong lei xing de shi jian dui xiang 。 yi zhong shi ren gong chong zhi de shi jian , ling yi zhong shi zi dong chong zhi de shi jian 。 dang ren gong chong zhi de shi jian de dao tong zhi shi , deng dai gai shi jian de suo you xian cheng yun bian wei ke tiao du xian cheng 。 dang yi ge zi dong chong zhi de shi jian de dao tong zhi shi , deng dai gai shi jian de xian cheng zhong zhi you yi ge xian cheng bian wei ke tiao du xian cheng 。 dang yi ge xian cheng zhi xing chu shi hua cao zuo , ran hou tong zhi ling yi ge xian cheng zhi xing sheng yu de cao zuo shi , shi jian shi yong de zui duo 。 shi jian chu shi hua wei wei tong zhi zhuang tai , ran hou , dang gai xian cheng wan cheng ta de chu shi hua cao zuo hou , ta jiu jiang shi jian she zhi wei yi tong zhi zhuang tai 。 zhe shi , yi zhi zai deng dai gai shi jian de ling yi ge xian cheng fa xian gai shi jian yi jing de dao tong zhi , yin ci ta jiu bian cheng ke tiao du xian cheng 。 zhe di er ge xian cheng zhi dao di yi ge xian cheng yi jing wan cheng le ta de cao zuo 。 HANDLE CreateEvent(PSECURITY_ATTRIBUTS psa, bool fManualRest, bool fInitialState, PCTSTR pszname); di yi ge shen shu yong lai zhi ding an quan shu xing , tong chang wo men yong null, zui hou yi ge shen shu yong lai zhi ding yi ge ming zi 。fManualRest, shen shu shi ge bu er zhi , ta neng gou gao su xi tong shi chuang jian yi ge ren gong chong zhi de shi jian huan shi chuang jian yi ge zi dong chong zhi de shi jian (FALSE)。fInitialState, shen shu yong yu zhi ming gai shi jian shi yao chu shi hua wei yi tong zhi zhuang tai (TRUE) huan shi wei tong zhi zhuang tai (FALSE)。 dang xi tong chuang jian shi jian dui xiang hou ,createEvent jiu jiang yu jin cheng xiang guan de ju bing fan hui gei shi jian dui xiang 。 qi ta jin cheng zhong de xian cheng ke yi huo de dui gai dui xiang de fang wen quan , fang fa shi shi yong zai pszName shen shu zhong chuan di de xiang tong zhi , shi yong ji cheng xing , shi yong DuplicateHandle han shu deng lai tiao yong CreateEvent, huo zhe tiao yong OpenEvent, zai pszName shu zhong she ding yi ge yu tiao yong CreateEvent shi she ding de ming zi xiang pi pei de ming zi 。 yi dan shi jian yi jing chuang jian , jiu ke yi zhi jie kong zhi ta de zhuang tai 。 dang tiao yong SetEvent shi , ke yi jiang shi jian gai wei yi tong zhi zhuang tai : dang tiao yong ResetEvent han shu shi , ke yi jiang gai shi jian gai wei wei tong zhi zhuang tai 。 zi dong chong zhi de shi jian yu ren gong chong zhi shi jian de qu bie zai yu , zi dong chong zhi shi jian zai xian cheng cheng gong di deng dai dao gai dui xiang shi , zi dong chong zhi de shi jian jiu hui zi dong chong zhi dao wei tong zhi zhuang tai 。 tong chang mei you bi yao wei zi dong chong zhi de shi jian tiao yong ResetEvent han shu , yin wei xi tong hui zi dong dui shi jian jin xing chong zhi yi ge li zi : [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif[/img][/url][url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif[/img][/url]...{ [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] zuo zhe :wudi_1982 [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] lian xi fang shi :wudi_1982@hotmail.com [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] ben dai ma zhi tie chu le yi xie bi jiao guan jian de bu fen [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif[/img][/url] zhuan zai qing zhu ming chu chu [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif[/img][/url]} [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]// li yong shi jian dui xiang yan shi tong bu de TThread pai sheng lei [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] TEventThread=class(TThread) [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] private [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] CurCount : integer;// dang qian ji shu [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] Flabel : TLabel;// xian shi dang qian ji shu de Tlabel zu jian [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] procedure GetRestult; [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] protected [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] procedure Execute;override; [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] public [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] constructor Create(Alabel : TLabel); [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] end; [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]var [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] EventHandle : THandle;// shi jian dui xiang de ju bing [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]//TEventThread de shi xian dai ma [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif[/img][/url][url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif[/img][/url]...{ TEventThread } [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]constructor TEventThread.Create(Alabel: TLabel); [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]begin [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] Flabel := Alabel; [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] inherited Create(False); [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]end; [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]procedure TEventThread.Execute; [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]var [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] i : integer; [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]begin [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] inherited; [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] CurCount := 0; [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] for i := 0 to 10000 do [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] begin [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] case WaitForSingleObject(EventHandle,5000) of [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] WAIT_OBJECT_0 : begin// ru guo deng dai dao shi jian dui xiang , ze jiang dang qian ji shu jia 1, bing qie xian shi zai zhi ding label shang [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] Inc(CurCount); [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] Synchronize(GetRestult); [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] Sleep(0); [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] // guan yu sleep,switchtoThread de shi yong qian mian yi jing shuo le [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] // SwitchToThread [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] //Application.ProcessMessages; [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] end;//WAIT_OBJECT_0 [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] WAIT_TIMEOUT : begin// chao shi ze zi dong chong zhi dang qian ji shu [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] CurCount := 0; [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] Synchronize(GetRestult); [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] SwitchToThread; [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] end; [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] end; [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] end; [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]end; [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]procedure TEventThread.GetRestult; [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]begin [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] Flabel.Caption := IntToStr(CurCount); [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]end; [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]// chuang ti dan yuan zhong ce shi TEventThread de yi xie dai ma [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]procedure TForm1.CreateTClick(Sender: TObject); [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]begin [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] // zhe li chuang jian le TEventThread xian cheng lei de liang ge shi li , mu de shi geng hao de yan shi zi dong chong zhi he shou dong chong zhi de qu bie [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] TEventThread.Create(labEvent); [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] TEventThread.Create(labEvent2); [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]end; [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]procedure TForm1.CreateEClick(Sender: TObject); [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]begin [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] // sheng cheng yi ge shi jian dui xiang , shi jian dui xiang de chong zhi fang shi yi ji chu shi hua zhuang tai tong guo liang ge checkBox lai jue ding [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] EventHandle := CreateEvent(nil,ckbxAutoReset.Checked, ckbxInitEventState.Checked,pchar('MyEvent')); [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]end; [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]procedure TForm1.SetEClick(Sender: TObject); [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]begin [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] // tong zhi [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] SetEvent(EventHandle); [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]end; [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]procedure TForm1.ResetEClick(Sender: TObject); [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]begin [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] // wei tong zhi [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] ResetEvent(EventHandle); [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]end; [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]procedure TForm1.closeClick(Sender: TObject); [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]begin [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] // zai ni que ding bu xu yao ci shi jian dui xiang de shi hou , ji de shi fang zi yuan [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] CloseHandle(EventHandle) [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]end; [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] li yong shi jian dui xiang yan shi tong bu de cheng xu jie mian [url=http://www.wangchao.net.cn/bbs/pydetail_566602.html][img]http://p.blog.csdn.net/images/p_blog_csdn_net/wudi_1982/ li yong shi jian dui xiang yan shi xian cheng tong bu de jie mian .JPG[/img][/url] zheng li shang shu dai ma , ran hou fen bie yong bu tong de pei zhi bu tong shun xu de dian ji an niu , ke yi rang ni dui shi jian dui xiang de shi yong jia shen le jie 。 nei gai fang shi de tong bu huan you hen duo zhong , dan yuan li ji ben dou yi yang , hou xu wen zhang dui jin ke neng de yi ci ju li lie ju 。 shen kao wen xian :《WINDOWS gai xin bian cheng 》 zhu : zhuan zai qing zhu ming chu chu , xie xie
󰈣󰈤
  免责声明:本文仅代表作者个人观点,与王朝网络无关。王朝网络登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述,其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
赏心悦目的模特儿(9)
赏心悦目的模特儿(8)
赏心悦目的模特儿(7)
赏心悦目的模特儿(6)
周六一日游--绿野翠蜂场(一)
骆驼峰
下一站上环
杂乱的几张Danang
 
>>返回首页<<
 
 
 为你推荐
 
 
 
 转载本文
 UBB代码 HTML代码
复制到剪贴板...
 
 热帖排行
 
 
 
 
 
©2005- 王朝网络 版权所有