[fpc-pascal] CloseThread needed? still unclear

Sven Barth pascaldragon at googlemail.com
Mon Nov 28 21:54:15 CET 2011


On 28.11.2011 21:25, noreply at z505.com wrote:
>> Am 14.11.2011 02:32, schrieb noreply at z505.com:
>>> First I thought I would post this to the mailing list to ask you what
>>> the
>>> proper way to program with threads is. If we must call closethread on MS
>>> Win machines but not unix machines, then something needs to change to
>>> make
>>> the threading in the RTL more cross platform (and all the docs would
>>> need
>>> to mention things about closethread if it is needed).
>>
>> The bug was already mentioned here
>> http://mantis.freepascal.org/view.php?id=13160 and fixed for 2.2.2.
>> "CloseThread" was implemented in a cross platform way.
>>
>> Regards,
>> Sven
>
> Hmm, but the compiler I'm using right now is a 2.4 and I think there is a
> leak if I don't call closethread.

That is exactly my point: CloseThread was implemented because of that 
leak (see the comments in the bug issue I linked to).

> CloseThread was implemented for
> EndThread or how does it get called? I think the closethread has to be
> called outside the thread rather than inside the thread from what I tried,
> but I don't know.

Yes, it must be called outside of your thread function. See also: 
http://www.freepascal.org/docs-html/rtl/system/closethread.html

If you still have a leak then you might want to post a little example 
showing the problem.

Regards,
Sven



More information about the fpc-pascal mailing list