[fpc-devel] Mutex!

Amir Aavani Aavani at iust.ac.ir
Mon Nov 6 20:32:53 CET 2006


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.





More information about the fpc-devel mailing list