I have an array of arrays of int.
DataArray[X][Y]
I would like to create a thread for each X, which iterates along Y. I cannot figure out h
Only final
values can be captured within a method-local-anonymous-inner-class. You need to change your code as follows :
for (int i = 0; i < X; i++) {
final int index = i;
threadPool.submit(new Runnable() {
public void run() {
Function_to_run(index);
}
});
Any local variable, formal method parameter or exception handler parameter used but not declared in an inner class must be declared final. Any local variable, used but not declared in an inner class must be definitely assigned before the body of the inner class.