threadExamples
Class BatonMessageBox<V>

java.lang.Object
  extended by threadExamples.BatonMessageBox<V>
Type Parameters:
V - The type of object that can be put into a BatonMessageBox.

public class BatonMessageBox<V>
extends java.lang.Object

Implements a message box which can hold only a single message at a time. Behavior is almost identical to that of SimpleMessageBox, but the implementation is different: put and get are not synchronized methods, but instead use an explicit (though otherwise unimportant) object for synchronization.

Version:
January 28, 2008
Author:
David Matuszek

Constructor Summary
BatonMessageBox()
          Creates an empty BatonMessageBox.
 
Method Summary
 V get()
          Waits until there is something in this BatonMessageBox, then removes and returns it.
 void put(V nextValue)
          Waits until this BatonMessageBox is empty, then puts the given object into it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BatonMessageBox

public BatonMessageBox()
Creates an empty BatonMessageBox.

Method Detail

put

public void put(V nextValue)
Waits until this BatonMessageBox is empty, then puts the given object into it.

Parameters:
nextValue - The object to be added.

get

public V get()
Waits until there is something in this BatonMessageBox, then removes and returns it.

Returns:
The object removed from this Queue.