/* Java version of mutexes */ class mutex { boolean lock = false; public synchronized void lock() throws InterruptedException { if (lock) wait(); lock = true; } public synchronized void unlock() throws InterruptedException { lock = false; notify(); // wakes up one thread waiting on this object // an alternative is to use notifyAll() with a while loop in lock() } } // mutex // Please don't confuse a thread and an instance of mutex. In ada, // the closes counterpart to the mutex class will be a protected type. class mythread implements Runnable { static mutex MU = new mutex(); // shared mutex - "static" is critical turnbroker TB; // not shared, but is a pointer to shared object int id; public mythread(int i, turnbroker T) { id = i; TB=T; } public void run() // required by Runnable interface { try { for(int i=0;i<10;i++) { TB.synch(); // synch with fairness broker MU.lock(); System.out.println(id+" is inside critical section"); MU.unlock(); System.out.println(id+" is doing asynch work."); Thread.sleep(id*2000); // delay for milliseconds } } catch (Exception e) {System.out.println(e);} } }//mythread //////////// Synchronization monitor - similar to "Fairnessmonitor" in Ada class turnbroker { int totalclients; int clients = 0; public turnbroker(int t) {totalclients = t;} public synchronized void synch() throws InterruptedException { clients++; if (clients