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

_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to