and the main thread:public class MyRun implements Runnable{ int[] array = new int[5]; int index; MyRun(int value, int index){ this.index = index; array[index] = value; } } //run() method to do operation public void run(){ System.out.println("run()"); for(int count = 0; count < 5; count++) System.out.println(array[count]); } }
import java.util.concurrent.*; public class satu { public static void main(String[]args){ int[] array = {4,2,3,1,5}; int lowest = array[0], highest = array[0]; int pivot; ExecutorService executor = Executors.newFixedThreadPool(1); for(int index = 1; index < array.length; index++){ //mission: find highest n lowest if(lowest > array[index]) lowest = array[index]; else if (highest < array[index]) highest = array[index]; } pivot = array[lowest + (highest - lowest)/2]; for(int count = 0; count < array.length; count++){ Runnable task = new MyRun(array[count],count); } executor.shutdown(); while(!executor.isTerminated()); System.out.println("Finish"); } }
Why my run() cant be execute? Please, please do help me..