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