[fpc-devel] Mutex!

Amir Aavani Aavani at iust.ac.ir
Sun Nov 5 06:09:17 CET 2006


  Let me explain the problem with more details,

consider the following code:

while true do
begin
  ReadLn (S);
/// Lock Mutex
  AThread:= TMyThread.Create (True);//Suspended
  AThread.Prepare (S);
  AThread.Resume;
///UnLock Mutex
end;
...

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




More information about the fpc-devel mailing list