This version seems to work. I used deadlock detection and it seems that the problem is the infinite loop design in run(). The output for this version is like this: 4 processes each request critical section 5 times. The last one will only send 3 requests. We should come up with a better setting