Hello guys,
i am stuck with this problem
i have a program quicksort and i want to draw graphics how the quicksort works, but here is a problem
how can i call thread method run() to to only a few steps of quicksort then repaint a graph, then quicksort then repaint..etc
here is my code for quicksorth algorithm i need to implement method run and in other class for example Painter
to use paint method to draw this graph, but step after step
public class QuickSort implements Runnable{
public void sort (int[] vstupnePole) {
QSort(vstupnePole,0,vstupnePole.length-1);
}
public void QSort(int[] array,int zac,int kon){
int i = zac;
int j = kon;
int pivot = array[(i+j)/2];
while(i<=j){
while(pivot<array[j]){j--;}
while(pivot>array){i++;}
if (i<=j){
int temp = array[i];
array[i] = array[j];
array[j] = temp;
i++;
j--;
}
}
if (zac<j){QSort(array,zac,j);}
if (i<kon){QSort(array,i,kon);}
}
}
i need to use thread.sleep() to have a few sec to paint my graph and then quicksort must continue,
how can i do this ? I am beginner with java threads (i can use them in a simple cycle not in a recursive method)
thanks in advance;)