Просмотр исходного кода

* count the number of successfully started threads, and quit as soon as
those threads have finished (rather than waiting for the maximum number
of threads that may have been started)

git-svn-id: trunk@20003 -

Jonas Maebe 13 лет назад
Родитель
Сommit
4e053637d4
1 измененных файлов с 5 добавлено и 2 удалено
  1. 5 2
      tests/test/tmt1.pp

+ 5 - 2
tests/test/tmt1.pp

@@ -46,13 +46,16 @@ function f(p : pointer) : ptrint;
 
 
 var
 var
    i : ptrint;
    i : ptrint;
+   started: longint;
 begin
 begin
    finished:=0;
    finished:=0;
+   started:=0;
 
 
    for i:=1 to threadcount do
    for i:=1 to threadcount do
-     BeginThread({$ifdef fpc}@{$endif}f,pointer(i));
+     if BeginThread({$ifdef fpc}@{$endif}f,pointer(i)) <> tthreadid(0) then
+       inc(started);
 
 
-   while finished<threadcount do
+   while finished<started do
      {$ifdef wince}sleep(10){$endif};
      {$ifdef wince}sleep(10){$endif};
    writeln(finished);
    writeln(finished);
 end.
 end.