[fpc-devel] Mutex!

Peter Vreman peter at freepascal.org
Sun Nov 5 11:18:56 CET 2006

At 06:09 5-11-2006, you wrote:
>  Let me explain the problem with more details,
>consider the following code:
>while true do
>  ReadLn (S);
>/// Lock Mutex
>  AThread:= TMyThread.Create (True);//Suspended
>  AThread.Prepare (S);
>  AThread.Resume;
>///UnLock Mutex
>To understand the EnterCriticalsection, I write the following 
>code,  I was expect to see a single "Here" while a lot of here is printed.
>Was I incorrect in anywhere?
>  InitCriticalSection (cs);
>  while true do
>  begin
>    EnterCriticalsection (cs);
>    WriteLn ('Here!');
>  end;
>    LeaveCriticalsection (cs);
>I referred to a document about EnterCriticalsection, It said that It 
>prevent two different thread to access a critical section, but here

Criticalsections are like recursive mutexes


More information about the fpc-devel mailing list