1 17 18 package org.apache.avalon.cornerstone.blocks.scheduler; 19 20 import java.util.NoSuchElementException ; 21 22 31 public final class SynchronizedPriorityQueue 32 implements PriorityQueue 33 { 34 private final PriorityQueue m_priorityQueue; 35 36 public SynchronizedPriorityQueue( final PriorityQueue priorityQueue ) 37 { 38 if( null == priorityQueue ) 39 { 40 throw new NullPointerException ( "priorityQueue" ); 41 } 42 m_priorityQueue = priorityQueue; 43 } 44 45 48 public void clear() 49 { 50 synchronized( m_priorityQueue ) 51 { 52 m_priorityQueue.clear(); 53 } 54 } 55 56 61 public boolean isEmpty() 62 { 63 synchronized( m_priorityQueue ) 64 { 65 return m_priorityQueue.isEmpty(); 66 } 67 } 68 69 74 public void insert( final Object element ) 75 { 76 synchronized( m_priorityQueue ) 77 { 78 m_priorityQueue.insert( element ); 79 } 80 } 81 82 88 public Object peek() throws NoSuchElementException 89 { 90 synchronized( m_priorityQueue ) 91 { 92 return m_priorityQueue.peek(); 93 } 94 } 95 96 102 public Object pop() throws NoSuchElementException 103 { 104 synchronized( m_priorityQueue ) 105 { 106 return m_priorityQueue.pop(); 107 } 108 } 109 110 public String toString() 111 { 112 synchronized( m_priorityQueue ) 113 { 114 return m_priorityQueue.toString(); 115 } 116 } 117 } 118 119 | Popular Tags |