title: Simple Lock-Free Stack
body: <p>Recently have found such java-concurrency interview task:</p>
  
  <blockquote>
    <p>Write simple lock-free Stack with two methods: push and pop.</p>
  </blockquote>
  
  <p>I made the concent:</p>
  
  <pre><code>import java.util.concurrent.atomic.AtomicInteger;
  
  
  public class Stack {
      private AtomicInteger count = new AtomicInteger(-1);
      private Object[] data = new Object[1000];
  
      public void push(Object o) {
          int c = count.incrementAndGet();
          data[c] = o;
      }
  
      public Object pop() {
          Object top;
          int c;
          while (true) {
              c = count.get();
              if (c == -1) return null;
              top = data[c];
              if (count.compareAndSet(c, c-1))
                  return top;
          }
      }
  }
  </code></pre>
  
  <p>Is it similar to approach was expected? Or "lock-free stack" means something different? Please, help a java-interview newbie.</p>