[Lazarus] Synchronize problem in linux
michael.vancanneyt at wisa.be
michael.vancanneyt at wisa.be
Wed May 25 12:22:53 CEST 2011
On Wed, 25 May 2011, Giuliano Colla wrote:
> Mattias Gaertner ha scritto:
>> This might help:
>> http://wiki.lazarus.freepascal.org/Multithreaded_Application_Tutorial
>>
>> Mattias
>>
>>
> I have a question related to this subject. Working with Borland's stuff
> (Kylix) I stumbled into a problem, and I'd like to know if the same applies
> also to Lazarus.
>
> I had a multithread application with a thread which receives data through a
> communication line. I thought it safe to use a TStringList, which AFAIK is
> not a visual object. The main thread would create the StringList, the other
> thread would append strings to the list, and when it was done, the main
> thread would perform the required processing. The logic of the application
> itself made it sure that there was no conflict whatsoever. It turned out that
> it didn't work at all, silently filling with garbage the List, and I was
> forced to move all code related to the StringList in the main thread, with a
> slight overhead which, IMO should not have been necessary. I couldn't
> understand if it was a Kylix bug or a feature.
>
> How would Lazarus behave with respect to this scenario? The scheme I
> described is expected to work?
No. You should use a TMultiReadExclusiveWriteSynchronizer object to
synchronize access to your object, or use a critical section.
Michael.
More information about the Lazarus
mailing list