void bubbleSort() {
for (int i = num - 2; i >= 0; i--) {
for (int j = 0; j <= i; j++) {
if (ar[j] > ar[j+1]) {
int t = ar[j];
ar[j] = ar[j+1];
ar[j+1] = t;
}
try {
Thread.sleep(SLEEP_SORT_MS);
} catch (InterruptedException e) {
e.printStackTrace();
}
draw();
}
}
}
I was making a program to visualize bubble sort using JavaFX, and Thread.sleep()
did not work properly. Is it possible to make JavaFX wait for a moment?