Hello Brian,

A word of warning : I've had problems with
TMultiReadExclusiveWriteSynchronizer where my code was written in such
as way as to upgrade a Read-Lock to a Write-Lock, which can lead to
dead locks. This won't work. You must release all Read-Locks before
attempting a Write-Lock. 

My experience with writing multi-threaded server applications had led
me to these rules of thumb:

1. Avoid using CriticalSections at all cost, except in
once-in-a-blue-moon situations, certainly not in the core loop.

2. Each thread should have it's own objects. By doing this you avoid
all threading issues altogether, such as lock-contention, memory
corruption, etc... This is a trading space (RAM) for speed, and as an
added bonus the programming complexity goes away. However, not all
global objects lend themselves to this technique, either because the
data it holds is critically global or because the data it holds to
just too large to multiply by the number of threads.

3. Inter-thread communication should only be done using a lock-free
technique, for example:
   (a) The windows message queue
   (b) Interlocked variable access (handy for setting flags)
   (c) A Lock-Free Queue (my preferred method)


   
-- 
Best regards,
 Stephen                            mailto:[EMAIL PROTECTED]


__________________________________________________
Delphi-Talk mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi-talk

Reply via email to