Hi,
I created a class with four methods. I inserted print statements into them, so I could see if they work properly. There is no problem with the first three. But when I call the fourth method nothing prints out. Strangely when I initiate debugger and move through the method step by step, the statements are called(and output printed). How can this be?
Thanks in advance.
Method in question:
public void robin(int counter, int quant, int penalty) {
if(Schedulers.quant==-1) {
Schedulers.quant=quant;
}
while(p!=null && p.getArrival()==counter) {
qrobin.add(p);
if(i.hasNext())
p=i.next();
else {
p=null;
break;
}
}
if(active!=null) {
if(active.getLeftOver()>0 && Schedulers.quant>0) {
active.decreaseLeftOver();
Schedulers.quant--;
System.out.print(active.getPID());
}
else if(active.getLeftOver()>0 && Schedulers.quant==0) {
qrobin.add(active);
active=qrobin.poll();
Schedulers.quant=quant;
Schedulers.quant--;
if(active!=null) {
System.out.print(active.getPID());
active.decreaseLeftOver();
}
else
System.out.print(" ");
}
else {
active=qrobin.poll();
Schedulers.quant=quant;
Schedulers.quant--;
if(active!=null) {
System.out.print(active.getPID());
active.decreaseLeftOver();
}
else
System.out.print(" ");
}
}
else {
active=qrobin.poll();
Schedulers.quant=quant;
Schedulers.quant--;
if(active!=null) {
System.out.print(active.getPID());
active.decreaseLeftOver();
}
else
System.out.print(" ");
}
}
Code calling it:
while(true){
algorithm(algorithm,s,counter);
counter++;
}