FileDocCategorySizeDatePackage
SynchronizedArrayStack.javaAPI DocExample753Mon Nov 13 12:11:54 GMT 2006collections

SynchronizedArrayStack

public class SynchronizedArrayStack extends Object implements Stack

Fields Summary
private final Stack
stack
Constructors Summary
public SynchronizedArrayStack(Stack stack)

    this.stack = stack;
  
Methods Summary
public synchronized booleanisEmpty()

 return stack.isEmpty(); 
public voidnotThreadSafe()

    Stack stack = new SynchronizedArrayStack(new ArrayStack());

    // don't do this in a multi-threaded environment
    if (!stack.isEmpty()) {
      stack.pop();              // can throw IllegalStateExceptionindexException{IllegalStateException}
    }
    synchronized(stack) {
      if (!stack.isEmpty()) {
        stack.pop();
      }
    }
  
public synchronized intpop()

 return stack.pop(); 
public synchronized voidpush(int elt)

 stack.push(elt);