Oracle Fusion Middleware Java API Reference for Oracle Extension SDK
11g Release 2 (11.1.2.0.0)

E17493-01

oracle.javatools.util
Class SynchronizedQueue

java.lang.Object
  extended by oracle.javatools.util.SynchronizedQueue

public class SynchronizedQueue
extends java.lang.Object

An unbounded synchronized queue.


Constructor Summary
SynchronizedQueue()
           
 
Method Summary
 void add(java.lang.Object object)
          Adds an object to this queue.
 void clear()
          Clears this queue.
 java.lang.Object first()
          Gets the first object in this queue.
 boolean isEmpty()
          Gets whether this queue is empty.
 boolean isEnabled()
          Gets whether this queue is enabled
 java.lang.Object last()
          Gets the last object in this queue.
 java.lang.Object remove()
          Removes an object from this queue; blocks if this queue is empty.
 java.lang.Object remove(long timeout)
          Removes an object from this queue; blocks for a specified interval if this queue is empty.
 void setEnabled(boolean enabled)
          Sets whether this queue is enabled.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SynchronizedQueue

public SynchronizedQueue()
Method Detail

add

public void add(java.lang.Object object)
Adds an object to this queue. If this queue is disabled, the object is discarded.

Parameters:
object - A non-null object.

remove

public java.lang.Object remove()
                        throws java.lang.InterruptedException
Removes an object from this queue; blocks if this queue is empty.

Returns:
The first object of this queue.
Throws:
java.lang.InterruptedException

remove

public java.lang.Object remove(long timeout)
                        throws java.lang.InterruptedException
Removes an object from this queue; blocks for a specified interval if this queue is empty.

Parameters:
timeout - A long giving the number of milliseconds to wait.
Returns:
The first object of this queue, or null if this queue is empty at the end of the specified interval.
Throws:
java.lang.InterruptedException

clear

public void clear()
Clears this queue.


setEnabled

public void setEnabled(boolean enabled)
Sets whether this queue is enabled. Disabling the queue is an alternative to stopping producer threads when the consumer thread is unable to consume.


isEnabled

public boolean isEnabled()
Gets whether this queue is enabled


isEmpty

public boolean isEmpty()
Gets whether this queue is empty. Note that by the time a calling thread examines the return value, other threads may have altered the state of the queue.


first

public java.lang.Object first()
Gets the first object in this queue. Note that by the time a calling thread examines the return value, other threads may have altered the state of the queue.

Returns:
The first object to be removed from this queue; null if the queue is empty.

last

public java.lang.Object last()
Gets the last object in this queue. Note that by the time a calling thread examines the return value, other threads may have altered the state of the queue.

Returns:
The last object added to this queue; null if this queue is empty.

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK
11g Release 2 (11.1.2.0.0)

E17493-01

Copyright © 1997, 2011, Oracle. All rights reserved.