// 上边接口的实现类。
public class SafeStack implements StackInterface {
private int top = 0;
private int[] values = new int[10];
private boolean dataAvailable = false;
public void push(int n) {
synchronized (this) {
while (dataAvailable) {
try {
wait();
} catch (InterruptedException e) {