Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Java, run/wait/run

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?

Name: Anonymous 2008-09-13 20:55

>>11
umm why dont you do some tail call optimization


int
main(void)
{
f:
  fork();
  goto f;
  return 255;
}

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List