TThreadList
As has been mentioned before, lists, stacks and queues are very common when
implementing communication between threads. The TThreadList class performs the
most basic sort of synchronization required between threads. In addition to all
the methods presented in TList, two extra methods are provided: Lock and Unlock.
The usage of these should be fairly obvious to readers who have managed to work
through the previous couple of chapters: The list is locked before being
manipulated, and unlocked afterwards. If a thread performs multiple operations
on the list that are required to be atomic, then the list must remain locked.
The list does not perform any implicit synchronization on objects which are owned
by a particular list. The programmer may wish to devise extra locking mechanisms
to provide this ability, or alternatively, use the lock on the list to cover all
operations on data structures owned by the list.