The simplest concurrency pattern

Posted by Ilya Kogan on Stack Overflow See other posts from Stack Overflow or by Ilya Kogan
Published on 2011-03-15T07:59:01Z Indexed on 2011/03/15 8:10 UTC
Read the original article Hit count: 243

Please, would you help me in reminding me of one of the simplest parallel programming techniques.

How do I do the following in C#:

Initial state:

semaphore counter = 0

Thread 1:

// Block until semaphore is signalled
semaphore.Wait(); // wait until semaphore counter is 1

Thread 2:

// Allow thread 1 to run:
semaphore.Signal(); // increments from 0 to 1

It's not a mutex because there is no critical section, or rather you can say there is an infinite critical section. So what is it?

© Stack Overflow or respective owner

Related posts about c#

Related posts about concurrency