Code example for PriorityQueue

0
		public int compare(ExtendedMessage arg0, ExtendedMessage arg1) {
			return arg0.priority.compareTo(arg1.priority);
		} 
	}	 
	 
	private PriorityQueue<ExtendedMessage> queue = new PriorityQueue<ExtendedMessage>(10,new ExtendedMessageComparator());
	 
	public void putMessage(Message msg, MessagePriority priority){
		queue.add(new ExtendedMessage(msg, priority));
	} 
	 
	public Message pollMessage(){
		return queue.poll().getMessage();
	} 
	 
	public int getSize(){ 
		return queue.size();
	} 
}