Queue implemented in Java