+/EE360P

distributed systems

git clone https://git.julia.blue/+/EE360P

Wei-Lun Hungadd chap. 2 and 3df69975

master
319 B15 linesraw
1public class CountingSemaphore {
2    int value;
3    public CountingSemaphore(int initValue) {
4        value = initValue;
5    }
6    public synchronized void P() {
7        while (value == 0) Util.myWait(this);
8        value--;
9         
10    }
11    public synchronized void V() {
12        value++;
13        notify();
14    }
15}