[fpc-pascal] How to use TThread?

Antonio Fortuny a.fortuny at sitasoftware.lu
Thu Apr 18 08:47:26 CEST 2013


First of all change the order of lines 25-26
     inherited Create(False);
     FreeOnTerminate := True;

instead of
     FreeOnTerminate := True;
     inherited Create(False);

The, drop the DoExecute procedure and replace it by the Execute 
procedure. It is useless to Synchronize a thread's procedure inside itself !
After the creation, the thread executes immediately the overriden 
procedure Execute because, at creation time (inherited Create(False); ) 
the thread is created in the state NON SUSPENDED. The use of the 
DoExecute is obviously useless
our program will execute the procedure Excute only once as there is no loop.


Sita Software
*Antonio Fortuny*
Senior Software engineer

220, avenue de la Liberté
L-4602 Niederkorn
Tel.: +352 58 00 93 - 93
www.sitasoftware.lu <http://www.sitasoftware.lu>
Your IT Partner

Le 18/04/2013 07:03, silvioprog a écrit :
> Hi,
>
> I tried to use TThread in a small sample, but it don't works. The code 
> is very simple, and I'm sending it in attached.
>
> Thanks,
>
> -- 
> Silvio Clécio
> My public projects - github.com/silvioprog <http://github.com/silvioprog>
>
>
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20130418/85a19078/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bahebfac.jpg
Type: image/jpeg
Size: 2306 bytes
Desc: not available
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20130418/85a19078/attachment.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gcijfcec.jpg
Type: image/jpeg
Size: 921 bytes
Desc: not available
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20130418/85a19078/attachment-0001.jpg>


More information about the fpc-pascal mailing list