.net sync

D

Daniel

i have an array that i want all threads to be able to READ from
concurrently, however, at times i want to UPDATE the array. at which point i
want all threads that use it to block when they try to read from the array.
currently i do this by wrapping ALL READ AND WRITE access to the array in a
lock("foobar"){} this prevernts threads from reading from the array while it
is being written to however it ALSO keeps more then one thread from reading
the array at a time. how to solve this so that multiple threads can read the
array at the same time but whent he array is being updated all threads that
want to read from it block until it updates, and so that the code to update
the array blocks until no thread is reading from the array before it starts
to update it?
 
J

Joshua Flanagan

That is exactly the problem the System.Threading.ReaderWriterLock class
is supposed to solve.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top