public double[] call() throws Exception {
int [] zero = {0,0};
double [] return_to_thread = { };
List<Integer> MyList = new ArrayList<Integer>();
for(int i = 0; i < N_W; i++) {
if(MyList.size() == n) {
N++;
}
MyList.clear();
int [] initial_point = {x,y};
for(int istep = 0; istep < n; istep++) {
randomWalk(initial_point);
if(!MyList.contains(computeHashCode(initial_point)) && !MyList.contains(computeHashCode(zero))) {
MyList.add(computeHashCode(initial_point));
} else {
break;
}
}
if(MyList.size() == n) {
end_to_end_dis_sq += Math.pow(initial_point[0], 2) + Math.pow(initial_point[1], 2);
}
}
return_to_thread[0] += N;
return_to_thread[1] += S;
// System.out.print(return_to_thread);
Thread.sleep(3000);
return return_to_thread;
}
The code above is the call() function that will return an array with double as the type.
public static void main(String [] args) {
ExecutorService service = Executors.newFixedThreadPool(1);
List<Future<double[]>> list = new ArrayList<Future<double[]>>();
Callable<double[]> callable = new Callable_class_1a();
for(int i = 0; i < 1; i++) {
//Submit the task for execution.
Future<double[]> future = service.submit(callable);
list.add(future);
}
for(Future<double[]> futu : list) {
try {
System.out.print(Arrays.toString(futu.get()));
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
} finally {
service.shutdown();
}
}
}
And the code above is the main function that supposed to print out the value that I get from call() function. I ran this on Eclipse, and when I clicked run nothing happened.
I wonder what happened, and how do I solve this? I can clarify any part that confused you. This is my first every question on Stackoverflow, hope everyone treat me nicely :)