[Lazarus] Mutlithreaded Dll Callback crashes my Application

Alexander Grau alex at grauonline.de
Fri Aug 27 15:23:29 CEST 2010


Sven Barth schrieb:
> Am 27.08.2010 12:27, schrieb Maik Wojcieszak:
>> Hi,
>>
>> What exactly does this
>>
>> System.IsMultiThread := true;
>>
>> do ?
>>
>> If I use external threads with my thread creation callback it works fine
>> with
>> System.IsMultiThread := false;
>> If I set it to true the app crashes when creating the first threads.
>> If I use the suggested initialisation with the dummy thread it works
>> too, but with
>> System.IsMultiThread := true;
>>
>> Thanks in advance,
>> Maik
>>
>
> I did a quick search in the source of the RTL. IsMultiThread is mostly 
> tested to check whether multi threading was already initialised. 
> Especially on POSIX systems you MUST NOT set IsMultiThread to True or 
> the threadvar system won't be initialized (win32 does a more 
> "intelligent" test).
>
> The interesting thing is though that IsMultiThread is never set to 
> True by the RTL in POSIX systems...
>
> The creation of a dummy thread should be enough. You can set 
> IsMultiThread to true after the thread has run though (to circumvent 
> the POSIX problem I mentioned above).

My attempt to summarize all (practical) aspects is online now (at the 
end of the page):

http://wiki.freepascal.org/Multithreaded_Application_Tutorial

If I should make corrections, just let me know.

Regards,
Alexander








More information about the Lazarus mailing list