I am trying to populate an array with random numbers in parallel.
When I build it using Eclipse I get the error: "There is an error in the required project - Threads"
Not very helpful! I'm at a loss as to what is wrong, any help would be appreciated.
public class PopulateArray extends Thread { private int f[]; private int a,b; private int x; public PopulateArray(int list[],int a, int b, int x){ f = list; this.a = a; this.b = b; this.x = x; } @Override public void run() { for(int j = a; j < b; j++) { f[j] = x; } } } public class ShuffleResult { public static void main(String[] args) { //Populate array int list[] = new int[100]; Thread t = new PopulateArray(list, 0 , 50 , (int)Math.random()* 100); Thread t1 = new PopulateArray(list, 50 , list.length , (int)Math.random()* 100); t.start(); t1.start(); try{ t.join(); t1.join(); } catch(InterruptedException e){ } //Print array for(int i : list){ System.out.print(list[i] + " "); } } }
If i proceed with the build the output is 100 zero's so obviously PopulateArray isn't doing anything?