ReaderWriterLock Class
ReaderWriterLock Class
This class implements a single-writer but multiple-reader semantics. Think of a file operations where only one and only one thread can write (make changes) to a particular file but the rest can only read. The four main methods in the class are:
(1) AcquireReaderLock() – It acquires a reader lock. It accepts an argument (integer or a TimeSpan) for timeout value.
(2) AcquireWriterLock() – This acquires a writer block. It accepts an argument (integer or a TimeSpan) for timeout value.
(3) ReleaseReaderLock() – Releases the reader lock.
(4) ReleaseWriterLock() – Release the writer lock.
Reader threads can acquire a lock only if there are no writers holding the lock.
Writer threads can acquire lock only if there are no readers or writers holding the lock.
Only Reader threads can have concurruent access to the object after acquiring the reader lock.
This class implements a single-writer but multiple-reader semantics. Think of a file operations where only one and only one thread can write (make changes) to a particular file but the rest can only read. The four main methods in the class are:
(1) AcquireReaderLock() – It acquires a reader lock. It accepts an argument (integer or a TimeSpan) for timeout value.
(2) AcquireWriterLock() – This acquires a writer block. It accepts an argument (integer or a TimeSpan) for timeout value.
(3) ReleaseReaderLock() – Releases the reader lock.
(4) ReleaseWriterLock() – Release the writer lock.
Reader threads can acquire a lock only if there are no writers holding the lock.
Writer threads can acquire lock only if there are no readers or writers holding the lock.
Only Reader threads can have concurruent access to the object after acquiring the reader lock.

0 Comments:
Post a Comment
<< Home