<div dir="ltr"><div class="gmail_default" style="font-family:courier new,monospace"><br></div><div class="gmail_extra"><div class="gmail_quote">2014-10-02 23:07 GMT+08:00 Jonas Maebe <span dir="ltr"><<a href="mailto:jonas.maebe@elis.ugent.be" target="_blank">jonas.maebe@elis.ugent.be</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><span class=""><br><div><div>On 02 Oct 2014, at 15:59, Xiangrong Fang wrote:</div></div><br></span><div>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).</div><span class="HOEnZb"><font color="#888888"><div><br></div></font></span></div></blockquote><div class="gmail_default" style="font-family:'courier new',monospace">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.</div><div class="gmail_default" style="font-family:'courier new',monospace"><br></div><div class="gmail_default" style="font-family:'courier new',monospace">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.</div><div class="gmail_default" style="font-family:'courier new',monospace"><br></div><div class="gmail_default" style="font-family:'courier new',monospace">Xiangrong</div><div class="gmail_default" style="font-family:'courier new',monospace"><br></div><div class="gmail_default" style="font-family:'courier new',monospace"><br></div></div></div></div>