org.opensubsystems.core.util
Class SynchronizedQueue

java.lang.Object
  extended by org.opensubsystems.core.util.SynchronizedQueue

public class SynchronizedQueue
extends java.lang.Object

Class that implement unlimited queue, that is synchronized. It means that the consumer of the objects from the queue waits/is blocked in the get method until there is an object available.

Version:
$Id: SynchronizedQueue.java,v 1.4 2007/01/07 06:14:00 bastafidli Exp $
Author:
Miro Halas
Code reviewer:
Miro Halas
Code reviewed:
Initial revision

Field Summary
protected  java.util.List m_lstObjects
          Cache of object produced by producer and consumed by consumer.
 
Constructor Summary
SynchronizedQueue()
          Constructor for Synchronized Queue Object.
 
Method Summary
protected  void finalize()
          Destructor for Synchronized Queue.
 java.lang.Object get()
          Get the object from the beginning of the queue
 boolean isEmpty()
          Test if the queue is empty.
 void put(java.lang.Object objNew)
          Put the object to the end of the queue.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_lstObjects

protected java.util.List m_lstObjects
Cache of object produced by producer and consumed by consumer.

Constructor Detail

SynchronizedQueue

public SynchronizedQueue()
Constructor for Synchronized Queue Object.

Method Detail

finalize

protected void finalize()
                 throws java.lang.Throwable
Destructor for Synchronized Queue. It is called when no other object holds reference to it.

Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable - - default destructor exception

get

public java.lang.Object get()
                     throws java.lang.InterruptedException
Get the object from the beginning of the queue

Returns:
Object - object from the queue, if the thread is blocked in this function and you call interrupt method, an InterruptedException will be thrown.
Throws:
java.lang.InterruptedException - - if the thread is blocked in this function and you call interrupt method, an InterruptedException will be thrown.

put

public void put(java.lang.Object objNew)
Put the object to the end of the queue.

Parameters:
objNew - - new object, can be null

isEmpty

public boolean isEmpty()
Test if the queue is empty.

Returns:
boolean - true if the queue is empty


Copyright © 2003 - 2006 OpenSubsystems s.r.o.