1.线程代码:
procedure TTest.Execute;
var
i:integer;
begin
{ Place thread code here }
OnTerminate:=Form1.Done;
if WaitForSingleObject(HMux,INFINITE)=WAIT_OBJECT_0 then
begin
for i:= 1 to 128 do
begin
Garry[i]:=form1.Getnum();
sleep(5);
end;
end;
//ReleaseMutex(HMux);
end;
end.
2.主体
procedure TForm1.Button1Click(Sender: TObject);
begin
HMux:=CreateMutex(nil,false,nil);
TTest.Create(false);
TTest.Create(false);
end;
请高手解释下WaitForSingleObject 在不使用//ReleaseMutex(HMux); 释放互斥体的情况下 程序应该一直把线程#2休眠,函数一直没有返回才对
吃鸡游戏
慕慕森