hi, i've got some problems regarding the thread of my project, as you can see in the picture i'm trying to show all the steps towards reaching the wanted number in a binary search but it skips to the final part even though i've put 5 seconds at each step. can somebody help me solve this issue, please?
colorLabel(Integer.toString(arrayLabel[0]), Color.BLUE);
colorLabel(Integer.toString(arrayLabel[arrayLabel.length-1]), Color.BLUE);
BinarySearchAlgorithm(arrayLabel, 0, arrayLabel.length-1, 1);
}
public void BinarySearchAlgorithm(int arr[], int l, int r, int x) {
int auxl=l, auxr=r, auxm;
while (l <= r) {
int m = l + (r - l) / 2;
colorLabel(Integer.toString(arrayLabel[m]), Color.BLUE);
if (arr[m] == x) {
colorLabel(Integer.toString(arrayLabel[m]), Color.GREEN);
return;
}
try {
Thread.sleep(5000);
} catch (InterruptedException ex) {
System.out.println(ex.toString());
}
if (arr[m] < x) {
l = m + 1;
colorLabel(Integer.toString(arrayLabel[auxl]), Color.BLACK);
colorLabel(Integer.toString(arrayLabel[l]), Color.BLUE);
}
else {
r = m - 1;
colorLabel(Integer.toString(arrayLabel[auxr]), Color.BLACK);
colorLabel(Integer.toString(arrayLabel[r]), Color.BLUE);
}
colorLabel(Integer.toString(arrayLabel[m]), Color.BLACK);
}
}```