/* From sun Java tutorial, allows locked access to a shared var, no race conditions */ import java.awt.*; import java.applet.*; import langevinSimResult; public class cubbyHole { private langevinSimResult contents; private boolean available = false; //constructor public cubbyHole (langevinSimResult con) { contents = con; } public synchronized langevinSimResult peek() { //allows returns a value //useful if we want to only block py until some thing //(i.e. get or peek) has returned value. available = false; notifyAll(); return contents; } public synchronized langevinSimResult get() { while (available == false) { try { wait(); } catch (InterruptedException e) { } } available = false; notifyAll(); return contents; } public synchronized void put(langevinSimResult value) { while (available == true) { try { wait(); } catch (InterruptedException e) { } } contents = value; available = true; notifyAll(); } }