ThreadLocalStack { public T pop() { Deque<T> stack = stackLocal.get(); if (stack == null || stack.isEmpty()) { return null; } T popped = stack.pollFirst(); if (stack.isEmpty()) { stackLocal.remove(); } return popped; }  T push(T item); T peek(); T pop(); T popOrError(); T get(); T getOrError(); void set(T item); void remove(); void with(T item, WithProcedure procedure);  }
@Test public void pop() { assertThat(stack.pop(), equalTo(INITIAL_VALUE)); }
@Test public void popNull() { stack.pop(); assertThat(stack.pop(), nullValue()); }