sleep
Hallo,
First sorry if my english's not very clear :S
im writing a little program which emulates the execution of a theoric language we use at college. The program must have a "step by step" mode which shows the state of the vars every iteration. So i show them in a TextArea, and I highlight the instruction i'm executing, to let it be seen i've put a sleep. The problem is that the program waits to be finished to show all the information, instead of showing a line per second as it do through the console. Any ideas?
This is the method i call every iteration if the execution is on step by step mode
private void stepByStep() throws InterruptedException {
Point pto=line(instruction);
ed.Texto.select(pto.x, pto.y);//To show the line im executing
sleep(1000);
ed.Texto.select(0, 0);
monitorizar();
}
private void monitorizar(){ // It writes in de TextArea the state of the vars
String s="";
for (int j=0;j<variables.length;j++){
s=s+"x"+(j+1)+"="+variables[j]+", ";
}
s=s.substring(0,s.length()-2);
ed.Errores.insert(("\n"+s),(ed.Errores.getText()).length());//><-
//It waits to the end of the program to be shown!!!
System.out.println(s);//<<--It's actually shown every second!!! why not the previous line too?
}

