1/**
2 * Copyright(C) 1998
3 * All Rights Reserved. Salih Yurttas, ZCubes, BitsOfCode Software Systems, Inc..
4 *
5 * Permission to use, copy, modify, and distribute this
6 * software and its documentation for EDUCATIONAL purposes
7 * and without fee is hereby granted provided that this
8 * copyright notice appears in all copies.
9 *
10 * @date : January 1, 1998.
11 * @author : Salih Yurttas.
12 */
13
14
15public class CubbyHole {
16
17 private int contents;
18 private boolean available=false;
19
20 public synchronized int get() {
21 while(!available)
22 try {
23 wait();
24 }
25 catch(InterruptedException iE) {}
26
27 available = false;
28 notifyAll();
29 return contents;
30 }
31
32 public synchronized void put(int value) {
33 while(available)
34 try {
35 wait();
36 }
37 catch(InterruptedException iE) {}
38
39 contents = value;
40 available = true;
41 notifyAll();
42 }
43
44}