import java.util.*; class Main { static Deque stack; static ArrayStack concurrentStack; static List[] poppedValues; static int TH = 10, NUM = 1000; // Each unsafe thread pushes N numbers and pops N, adding // them to its own poppedValues for checking; using Java's // sequential stack implementation, ArrayDeque. static Thread unsafe(int id, int x, int N) { return new Thread(() -> { String action = "push"; try { for (int i=0, y=x; i { String action = "push"; try { for (int i=0, y=x; i set = new HashSet<>(); boolean passed = true; for (int i=0; i(); concurrentStack = new ArrayStack<>(TH*NUM); poppedValues = new List[TH]; for (int i=0; i(); Thread[] threads = new Thread[TH]; for (int i=0; i