KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > EDU > oswego > cs > dl > util > concurrent > misc > FIFOSlot


1 package EDU.oswego.cs.dl.util.concurrent.misc;
2 import EDU.oswego.cs.dl.util.concurrent.*;
3
4
5 // demo showing one way to make special channels
6

7 public class FIFOSlot implements BoundedChannel {
8   private final Slot slot_;
9
10   public FIFOSlot() {
11     try {
12       slot_ = new Slot(FIFOSemaphore.class);
13     }
14     catch (Exception JavaDoc ex) {
15       ex.printStackTrace();
16       throw new Error JavaDoc("Cannot make Slot?");
17     }
18   }
19
20   public void put(Object JavaDoc item) throws InterruptedException JavaDoc {
21     slot_.put(item);
22   }
23
24   public boolean offer(Object JavaDoc item, long msecs) throws InterruptedException JavaDoc {
25     return slot_.offer(item, msecs);
26   }
27
28   public Object JavaDoc take() throws InterruptedException JavaDoc {
29     return slot_.take();
30   }
31
32   public Object JavaDoc poll(long msecs) throws InterruptedException JavaDoc {
33     return slot_.poll(msecs);
34   }
35
36   public int capacity() { return 1; }
37
38   public Object JavaDoc peek() {
39     return slot_.peek();
40   }
41 }
42
43
44
Popular Tags