I'm displaying progress in the console, and using the '\r' character to clear the line between each update, as per this answer.
public class MainTest {
public static int delay = 10;
public static void main(String[] args) {
for (int i = 0; i <= 100; i++) {
System.out.print("\r");
System.out.print("process:" + i + "%");
Thread.sleep(delay);
}
}
}
With a delay of 240 ms or more, it seems to works fine. However, once I go below this, the '\r' character is not reliable. It looks jittery, and doesn't always clear the line, so at the end you see
process:97%process:98%process:99%process:100%
This gif shows the difference between update speeds. I don't want my program to run slower, just so that the console output looks nice. How can I fix this?