Marcus
Marcus

Reputation: 113

Ordering in ReaderWriterLock

When I use lock(){...}, I cannot garantee which thread will enter the lock first.

What about ReaderWriterLock? Does it works like a FIFO for the writers or not?

Upvotes: 2

Views: 456

Answers (1)

Richard
Richard

Reputation: 109180

What about ReaderWriterLock? Does it works like a FIFO for the writers or not?

It does.

And you pay a performance penalty for this, which is why ReaderWriterLockSlim was introduced—less overhead but it isn't "fair".

Upvotes: 3

Related Questions