Ole J. Røtne wrote: > > Can anyone explain why i get output like this in a small test program: > Inside Thread > Main Loop > Inside Thread > Main Loop > Inside Thread > Main Loop > > > On Windows the output are lined up just as I would expect: > Inside Thread > Main Loop > Inside Thread > Main Loop > > Here's a snip of the code: > > // Main Prog > > Thr := threadtest.Create; > > Repeat > k := PollKeyEvent; > WriteLn('Mein Loop'); > Sleep(100); > Until k <> 0; > > And the ThreadTest.Execute i just: > > Procedure ThreadTest.Execute; > Begin > Repeat > WriteLn('Inside Thread'); > Sleep(100); > Until Terminated > End; > > > And if this is a "wrong way" of doing this thing, could someone tell me how > it should be..
You probably want to guard the output with mutexes or semaphores. Writing unsynchronized to a stream has always unexpected results. > > Oh and BTW. Using FPC 2.1.1 snapshot from 14.06.06 (from Lazarus site), on > OpenSuSe 10.1.. > > > > > > _______________________________________________ > fpc-pascal maillist - fpc-pascal@lists.freepascal.org > http://lists.freepascal.org/mailman/listinfo/fpc-pascal _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal