Round robin

preciso fazer um trabalho sobre o roundrobin…
eu consigo criar as threads e rodar elas por prioridade…soh q entra num looping infinito e nao consigo parar…resumindo…queria parar qdo a pessoa apertasse qualquer tecla…mas ja tentei com InputStream e nao funciona…
segue um pedaço do codigo
public class Scheduler extends Thread
{
private Fila fila;
private int tempoEspera;
private static final int TEMPO_ESPERA_PADRAO = 1000; // 1 second

public Scheduler(int quantum) {
tempoEspera = quantum;
fila= new Fila();
}

public Scheduler() {
tempoEspera = TEMPO_ESPERA_PADRAO;
fila = new Fila();
}

void addThread(Thread t) {
t.setPriority(2);

  fila.addItem(t);   

}

private void gerenciadorSleep() {
try {
Thread.sleep(tempoEspera);
} catch (InterruptedException e) { };
}

public void run() {
Thread current;

  this.setPriority(6);
  
  while (true) {
	  	try {
            current = (Thread)fila.getNext();
        
           if ( (current != null) && (current.isAlive()) ) {
                 current.setPriority(4);
           
                 gerenciadorSleep();
                 
                 Logger.outPutRelatorio("=*=*= Thread realocada =*=*=");
           
                 current.setPriority(2);
           }
                 
        } catch (NullPointerException e3) { } ;
  }

}
}

class TestThread extends Thread
{
private String name;

public TestThread(String id) {
name = id;
}

public void run() {

/* 
 * The thread does something
 **/
  while (true) {    	  
	  for (int i = 0; i < 500000; i++);
   	  Logger.outPut("I am thread " + name);
	  Logger.outPutRelatorio("I am thread " + name);
  }

}
}

se alguem puder me ajudar :slight_smile: