threadExamples
Class Channel<V,W>

java.lang.Object
  extended by threadExamples.Channel<V,W>
Type Parameters:
V - The type of object used as a request.
W - The type of object used as a response.

public class Channel<V,W>
extends java.lang.Object

A pair of Queues, representing a two-way channel between Threads. The Queues are synchronized.

Although it isn't required, the intended use of a Channel is asymmetric: One Thread puts requests into the Channel, and another Thread services those requests and returns a response.

Version:
January 28, 2008
Author:
David Matuszek

Constructor Summary
Channel()
          Creates a new Channel (a pair of Queues).
 
Method Summary
 V getRequest()
          Gets an Object of type V from the request queue.
 W getResponse()
          Gets an Object of type W from the response queue.
 void putRequest(V value)
          Puts an Object of type V into the request queue.
 void putResponse(W value)
          Puts an object of type W into the response queue.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Channel

public Channel()
Creates a new Channel (a pair of Queues).

Method Detail

putRequest

public void putRequest(V value)
Puts an Object of type V into the request queue.

Parameters:
value - The object to be added.

getRequest

public V getRequest()
Gets an Object of type V from the request queue.

Returns:
The Object removed from the request queue.

putResponse

public void putResponse(W value)
Puts an object of type W into the response queue.

Parameters:
value - The object to be added.

getResponse

public W getResponse()
Gets an Object of type W from the response queue.

Returns:
The Object removed from the response queue.