KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > util > concurrent > NoExceptionLinkedQueue


1 /**
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright
3  * notice. All rights reserved.
4  */

5 package com.tc.util.concurrent;
6
7 import EDU.oswego.cs.dl.util.concurrent.Channel;
8 import EDU.oswego.cs.dl.util.concurrent.LinkedQueue;
9
10 public class NoExceptionLinkedQueue implements Channel {
11   public final LinkedQueue queue = new LinkedQueue();
12
13   public void put(Object JavaDoc o) {
14     while (true) {
15       try {
16         queue.put(o);
17         return;
18       } catch (InterruptedException JavaDoc e) {
19         //
20
}
21     }
22   }
23
24   public boolean offer(Object JavaDoc o, long l) {
25     try {
26       return queue.offer(o, l);
27     } catch (InterruptedException JavaDoc e) {
28       return false;
29     }
30   }
31
32   public boolean isEmpty() {
33     return queue.isEmpty();
34   }
35
36   public Object JavaDoc peek() {
37     return queue.peek();
38   }
39
40   public Object JavaDoc poll(long arg0) {
41     try {
42       return queue.poll(arg0);
43     } catch (InterruptedException JavaDoc e) {
44       return null;
45     }
46   }
47
48   public Object JavaDoc take() {
49     while (true) {
50       try {
51         return queue.take();
52       } catch (InterruptedException JavaDoc e) {
53         //
54
}
55     }
56   }
57
58   public boolean equals(Object JavaDoc obj) {
59     return queue.equals(obj);
60   }
61
62   public int hashCode() {
63     return queue.hashCode();
64   }
65
66   public String JavaDoc toString() {
67     return queue.toString();
68   }
69 }
70
Popular Tags