[fpc-devel] Mutex!

Michael Müller mueller_michael at nikocity.de
Sun Nov 5 13:46:00 CET 2006


Am 05.11.2006 um 12:14 schrieb Colin Western:

> Amir Aavani wrote:
>>  InitCriticalSection (cs);
>>  while true do
>>  begin
>>    EnterCriticalsection (cs);
>>    WriteLn ('Here!');
>>  end;
>>    LeaveCriticalsection (cs);
>
> Each Enter.. must be matched by a Leave..., and you don't need the  
> loop. The standard way of doing this is:

I'm sure that this is clear for Amir. But in his example he (and me  
too) expects that the loop should stop at the second time it calls  
EnterCriticalsection() because the old critical section wasn't left.

> EnterCriticalsection (cs);
> try
>   WriteLn ('Here!');
> finally
>   LeaveCriticalsection (cs);
> end;

But this is not an example to show how a critical section stops  
another one.

Regards

Michael





More information about the fpc-devel mailing list