Name: Anonymous 2008-09-12 23:03
I've written a program in Java that will let you select the number of 'steps' you want it to take (these represent days in the simulation).
Now I made a run option too but I can not get it to work properly.
I want it to run for X steps, after every step it needs to update the views.
This is what I tried:
for (int i = 0;i<100;i++) {
try {
model.simulate(1); (simulates 1 step)
Thread.currentThread().sleep(500);
} catch (InterruptedException e1) {
e1.printStackTrace();
}
}
The problem is that it will not update the views, only after 100 steps have been completed it will update the views.
I update the views using setChanged() & notifyObservers() which works when I manually do 1 step.
Any suggestions?
Now I made a run option too but I can not get it to work properly.
I want it to run for X steps, after every step it needs to update the views.
This is what I tried:
for (int i = 0;i<100;i++) {
try {
model.simulate(1); (simulates 1 step)
Thread.currentThread().sleep(500);
} catch (InterruptedException e1) {
e1.printStackTrace();
}
}
The problem is that it will not update the views, only after 100 steps have been completed it will update the views.
I update the views using setChanged() & notifyObservers() which works when I manually do 1 step.
Any suggestions?