marshian
New Member
- Messages
- 526
- Reaction score
- 9
- Points
- 0
I'm trying to make a thread which shows the time that had been required for a executing a command...
In other words: it stores the starttime, executes a command, and compares the start time to the current time.
But somewhere, something is going wrong, and the start time is always equal to the end time, even while I know it isn't.
This is my code:
Could anyone please help me?
Why is starttime always equal to endtime?
Thanks,
Marshian
In other words: it stores the starttime, executes a command, and compares the start time to the current time.
But somewhere, something is going wrong, and the start time is always equal to the end time, even while I know it isn't.
This is my code:
Code:
public void run() {
try {
for (; steps <= endstep; steps++) {
if (steps == 0) {
Main.graphicview.points = points;
Main.graphicview.repaint();
Thread.sleep(sleep);
continue;
}
long starttime = Calendar.getInstance().getTimeInMillis();
Main.statusbarTextLeft.setText(" Berekenen...");
Thread nextStep = new Thread(new Curve());
nextStep.start();
nextStep.join();
Main.graphicview.points = Curve.points;
Main.graphicview.repaint();
long endtime = Calendar.getInstance().getTimeInMillis();
Main.statusbarTextLeft.setText(" Berekening: "+(endtime-starttime)+" ms");
Thread.sleep(sleep);
}
} catch (InterruptedException ex) {
System.out.println("Thread interrupted.");
return;
}
if(steps >= endstep) return;
}
Could anyone please help me?
Why is starttime always equal to endtime?
Thanks,
Marshian