Delphi-Quellcode:
procedure TMyOwnThread.HighCondition;
begin
FetchedCount:=FetchedCount+1;
end;
procedure TMyOwnThread.ResetCondition;
begin
FetchedCount:=0;
end;
procedure TMyOwnThread.WriteResults;
begin
Form1.Memo1.Lines.Add('blaa');
end;
procedure TMyOwnThread.Execute;
begin
while not Terminated do
begin
Synchronize(HighCondition);
if FetchedCount>50 then
begin
Sleep(10000);
Synchronize(ResetCondition);
end;
Synchronize(WriteResults);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
Thread: TMyOwnThread;
ThreadCount: Integer;
begin
ThreadCount:=100;
for i:=0 to ThreadCount-1 do
begin
Thread:=TMyOwnThread.Create(True);
Thread.FreeOnTerminate := True;
Thread.Resume;
end;
end;
Habe hier nochmal den kompletten Code zur Veranschaulichung gekürzt ..