Selective Repeat Implement in Java