1 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 o) { 14 while (true) { 15 try { 16 queue.put(o); 17 return; 18 } catch (InterruptedException e) { 19 } 21 } 22 } 23 24 public boolean offer(Object o, long l) { 25 try { 26 return queue.offer(o, l); 27 } catch (InterruptedException e) { 28 return false; 29 } 30 } 31 32 public boolean isEmpty() { 33 return queue.isEmpty(); 34 } 35 36 public Object peek() { 37 return queue.peek(); 38 } 39 40 public Object poll(long arg0) { 41 try { 42 return queue.poll(arg0); 43 } catch (InterruptedException e) { 44 return null; 45 } 46 } 47 48 public Object take() { 49 while (true) { 50 try { 51 return queue.take(); 52 } catch (InterruptedException e) { 53 } 55 } 56 } 57 58 public boolean equals(Object obj) { 59 return queue.equals(obj); 60 } 61 62 public int hashCode() { 63 return queue.hashCode(); 64 } 65 66 public String toString() { 67 return queue.toString(); 68 } 69 } 70 | Popular Tags |