title: What will be the critical section code for a shared queue accessed by two threads?
body: <p>Suppose we have a shared queue (implemented using an array), which two threads can access, one for reading data from it, and other for writing data to it. Now, I have a problem of synchronization. I'm implementing this using Win32 API's (EnterCriticalSection etc.).</p>
  
  <p>But my curiosity is what will be the critical section code in enqueue and dequeue operations of the queue? </p>
  
  <p>Just because, two threads are using a shared resource? Why I'm not able to see any problem is this: front and rear are maintained, so, when ReaderThread reads, it can read from front end and when WriterThread writes, it can easily write to rear end.</p>
  
  <p>What potential problems can occur?</p>