[fpc-devel] Mutex!

Colin Western mftq75 at dsl.pipex.com
Sun Nov 5 12:14:05 CET 2006


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:

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



More information about the fpc-devel mailing list