|
Service Activator Toolkit
Version 1.1.0 (20081206) |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface IQueue
The IQueue
interface defines a FIFO container. An instance of
IQueue
can be created using the FactoryUtility
singleton.
FactoryUtility utility = FactoryUtility.getInstance(); IQueue queue = utility.createQueue(10);Objects are added to the queue using the
add(Object)
method.
queue.add("Monday"); queue.add("Tuesday"); queue.add("Wednesday");Objects are removed from the queue using the
remove()
method
that blocks while the queue is empty.
try { while (true) { String day = (String) queue.remove(); processDay(day); } } catch (InterruptedException exception); // OK }Object can also be removed from the queue using the
remove(long)
method that blocks for at least the specified millisecond timeout while the
queue is empty.
try { while (true) { String day = (String) queue.remove(1000); // Block for at least 1 second. if (day == null) break; // The queue is empty. processDay(day); } } catch (InterruptedException exception); // OK }
FactoryUtility
Method Summary | |
---|---|
void |
add(Object item)
Add the specified item to the queue. |
boolean |
contains(Object item)
Check to see if the specified item exists in the queue. |
boolean |
isEmpty()
Check to see if the queue is empty. |
Object |
remove()
Remove and return the next item in the queue. |
Object |
remove(long timeout)
Remove and return the next item in the queue. |
int |
size()
Query the size of the queue. |
Method Detail |
---|
void add(Object item)
item
- The item to add to the queue.boolean contains(Object item)
item
- The item to check for.
boolean isEmpty()
Object remove() throws InterruptedException
InterruptedException
Object remove(long timeout) throws InterruptedException
timeout
- The number of milliseconds to wait for the queue to no
longer be empty.
InterruptedException
int size()
|
Service Activator Toolkit
Version 1.1.0 (20081206) |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright © 2001, 2008 IBM Corporation and others. All Rights Reserved.