1 17 package org.apache.catalina.util; 18 19 import java.util.Vector ; 20 21 28 public class Queue { 29 private Vector vector = new Vector (); 30 31 37 public synchronized void put(Object object) { 38 vector.addElement(object); 39 notify(); 40 } 41 42 46 public synchronized Object pull() { 47 while (isEmpty()) 48 try { 49 wait(); 50 } catch (InterruptedException ex) { 51 } 52 return get(); 53 } 54 55 59 public synchronized Object get() { 60 Object object = peek(); 61 if (object != null) 62 vector.removeElementAt(0); 63 return object; 64 } 65 66 69 public Object peek() { 70 if (isEmpty()) 71 return null; 72 return vector.elementAt(0); 73 } 74 75 78 public boolean isEmpty() { 79 return vector.isEmpty(); 80 } 81 82 85 public int size() { 86 return vector.size(); 87 } 88 } 89 | Popular Tags |