Java implemention of GBN algorithm