On Wed, 25 May 2011 12:22:53 +0200 (CEST) [email protected] wrote:
> > > 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. Ehm, he made sure that only one thread accesses the TStringList at a time. Why should TMultiReadExclusiveWriteSynchronizer be necessary? Mattias -- _______________________________________________ Lazarus mailing list [email protected] http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
