What you suggested is a kind of busy waiting. But I want a suspension.
In a message , i described my  main problem which was a while like this.

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

And I told to check if Criticalsession could work in my situation i write that sample code.

Any idea for my problem?
Vinzent Höfler wrote:
Amir Avani wrote:

Thanks Michael, you are right!
I want to know how should I use Criticalsections to make my program to
print only one "here".

By not using them at all?

count := 0;

while true do
begin
   if count = 0
      WriteLn ('Here!');

   count := 1;
end {while};

Critical sections don't make sense in a non-threading context.


Vinzent.


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

Reply via email to