java - Understanding mutal exclusion lock -


i'm reading documentation readwritelock

whether or not read-write lock improve performance on use of mutual exclusion lock depends on frequency data read compared being modified, duration of read , write operations, , contention data - is, number of threads try read or write data @ same time.

what "mutual exclusion lock" mean? mean can perform 1 operation (reading or writing) @ time? instance, synchronized block.

a mutual exclusion lock ensure 1 operation can performed @ time (one reader or 1 writer).

according javadoc of readwritelock:

the read lock may held simultaneously multiple reader threads, long there no writers. write lock exclusive.

in practice means if have large number of writers, becomes hard readers gain access single writer lock out readers. alternatively, if have many readers performing short reads overhead of readwritelock perform worse simple mutual exclusion lock readwritelock has greater overhead.

i have paraphrased section of javadoc:

for example, collection populated data , thereafter infrequently modified, while being searched (such directory of kind) ideal candidate use of read-write lock. however, if updates become frequent data spends of time being exclusively locked , there little, if increase in concurrency. further, if read operations short overhead of read-write lock implementation (which inherently more complex mutual exclusion lock) can dominate execution cost, particularly many read-write lock implementations still serialize threads through small section of code


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -