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();
}
}