1 14 15 package EDU.oswego.cs.dl.util.concurrent; 16 import java.lang.reflect.*; 17 18 30 31 public class Slot extends SemaphoreControlledChannel { 32 33 45 46 public Slot(Class semaphoreClass) 47 throws NoSuchMethodException , 48 SecurityException , 49 InstantiationException , 50 IllegalAccessException , 51 InvocationTargetException { 52 super(1, semaphoreClass); 53 } 54 55 58 public Slot() { 59 super(1); 60 } 61 62 63 protected Object item_ = null; 64 65 66 67 protected synchronized void insert(Object x) { 68 item_ = x; 69 } 70 71 72 protected synchronized Object extract() { 73 Object x = item_; 74 item_ = null; 75 return x; 76 } 77 78 public synchronized Object peek() { 79 return item_; 80 } 81 82 } 83 | Popular Tags |