2014-10-02 23:07 GMT+08:00 Jonas Maebe <jonas.ma...@elis.ugent.be>: > > On 02 Oct 2014, at 15:59, Xiangrong Fang wrote: > > It will make your program unstable (adding an element to an fplist can > cause the entire internal array to move, so if you are in the middle of a > read operation at the same time, that read operation will either read > invalid data or crash). Unless you are an expert at multithreaded > programming, don't try to optimise existing thread-safe structures (and > definitely don't perform premature optimisations). > > I don't intend to do any optimization. I just think that I need to enter a critical section, add item to the list, then leave the critical section.
I am definitely not expert in thread programming, but I am clear about the logic of my class and program. Actually, it is a TTree object I wrote, using TFPList to store sibling nodes. There are a lot of TFPList (one per tree node). I just need to make sure that there are no more than one thread operating on the same node at the same time. Xiangrong
_______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal