Tom Kelliher, CS 245
Oct. 4, 2002
Read Chapter 6.
Introduction to threads.
Game2D case study.

class Queue
{
private int val;
private boolean full = false;
private boolean empty = true;
public Queue()
{
val = 0;
}
public synchronized void put(int v)
{
while (full)
try
{
wait();
}
catch (Exception e)
{
}
val = v;
full = true;
empty = false;
notify();
}
public synchronized int get()
{
while (empty)
try
{
wait();
}
catch (Exception e)
{
}
full = false;
empty = true;
notify();
return val;
}
}