Pastebin

Paste #441: thread race

< previous paste - next paste>

Pasted by Flawless

Download View as text

procedure SetGlobal(X: XInt);
begin
  SomeGlobalVar := X;
end;

function ThreadTest2(Sender: Pointer): DWord; stdcall;
begin
  SetGlobal(GlobalTestValue);
  SetGlobal(GlobalTestValue);
  SetGlobal(GlobalTestValue);
  SetGlobal(GlobalTestValue);
  SetGlobal(GlobalTestValue);
  Result := 2;
  ExitThread(4);
end;

{ test }
begin
  H := CreateThread(nil, 1024*10, @ThreadTest2, nil, 0, nil);
  TerminateThread(H, xsOK);
  WaitForSingleObject(H, INFINITE);
  GetExitCodeThread(H, U);
end;

New Paste


Do not write anything in this field if you're a human.

Go to most recent paste.