* let theapthread wait unneededly less so the total run time is shorter

git-svn-id: trunk@48388 -
This commit is contained in:
florian 2021-01-24 13:26:49 +00:00
parent 9c265d71f0
commit 402876bc1f

View File

@ -15,12 +15,14 @@ type
tpair = class;
tproducethread = class(tthread)
running: boolean;
pair: tpair;
constructor create(apair: tpair);
procedure execute; override;
end;
tconsumethread = class(tthread)
running: boolean;
pair: tpair;
constructor create(apair: tpair);
procedure execute; override;
@ -197,11 +199,13 @@ end;
procedure tproducethread.execute;
begin
running:=true;
producer(pair);
end;
procedure tconsumethread.execute;
begin
running:=true;
consumer(pair);
end;
@ -221,7 +225,12 @@ begin
pairs[i] := tpair.create;
for i := low(pairs) to high(pairs) do
pairs[i].resume;
sleep(1500);
{ wait till all threads are really resumed }
for i := low(pairs) to high(pairs) do
while not(pairs[i].produce_thread.running) or not(pairs[i].consume_thread.running) do
sleep(100);
done := true;
for i := low(pairs) to high(pairs) do
begin