I have recently switched to TSimpleRWSync from TRTLCriticalSection. The methods BeginRead and BeginWrite confuse me as wherever I read help, they seemingly do the same thing i.e. acquire the critical section whenever it gets relinquished. As the TSimpleRWSync doesn't allow multiple read threads, there is seemingly no point in having two separate methods either.

Is there a special difference between them aside from the contextual one?

1 Answer 1


The BeginRead/BeginWrite methods come from the IReadWriteSync interface. TSimpleRWSync is a simple implementation of that interface, allowing access only to a single reader or writer. But there is also another implementation of the interface (TMultiReadExclusiveWriteSynchronizer) which allows multiple concurrent readers.

By having both implementations conform to the same interface, you can easily replace your use of TSimpleRWSync with TMultiReadExclusiveWriteSynchronizer without having to touch all the places where you lock/unlock the critical sections. The only thing you need to do up front is forget that TSimpleRWSync allows only a single reader/writer and write your locking as if there can be multiple readers.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.