Sandor

Sandor

  • NA
  • 1
  • 0

Array as a buffer in multithreading

Oct 28 2007 7:46 AM

Hello!

I have an array of MemoryStreams. The main thread is updating one element at a time and the other threads are iterating over the array and checking if they are free to read the elements. If a MemoryStream is locked in the array, they won't read it and continue to another MemoryStream in the array.

How can I implement this scenario? I'm using the array as a buffer, the threads are reading from it and sending data over network, that's why I can't allow the main thread do the work of reading and sending the data. I need to make the other threads recognize and not read the element that is being updated.

Thank you