/* Semaphore, shared data structures in Java */ class Semaphore { private int val = 1; private int max; public Semaphore(int m) { val = max = m; } public synchronized void P() // wait/proberen { try { if (val<1) wait(); val--; } catch (InterruptedException iex) {System.out.println(iex+", val="+val); } } public synchronized void V() // signal/verhogen { if (val