NUM_THREADS=Integer.parseInt(args[++i]);
}
}
Address sender=Util.createRandomAddress("A");
TimeScheduler timer=new TimeScheduler3();
NakReceiverWindow win=new NakReceiverWindow(sender, new Retransmitter.RetransmitCommand() {
public void retransmit(long first_seqno, long last_seqno, Address sender) {
System.out.println("-- retransmit(" + first_seqno + "-" + last_seqno);
}
}, 0, timer, true);
// win.setRetransmitTimeouts(new ExponentialInterval(1000));
final CountDownLatch latch=new CountDownLatch(1);
Remover remover=new Remover(win, latch);
remover.start();
Adder[] adders=new Adder[NUM_THREADS];
for(int i=0; i < adders.length; i++) {
adders[i]=new Adder(win, latch, added);
adders[i].start();
}
Util.sleep(1000);
long start=System.currentTimeMillis();
latch.countDown();
while(remover.isAlive()) {
System.out.println("added messages: " + added + ", removed messages: " + removed);
remover.join(2000);
}
long diff=System.currentTimeMillis() - start;
System.out.println("added messages: " + added + ", removed messages: " + removed);
System.out.println("took " + diff + " ms to insert and remove " + NUM_MSGS + " messages");
win.destroy();
timer.stop();
}