I want to run a multithreaded program on massive data. I usually create a class which is callable (or runnable) and pass the data needed for the process to the class.
public class CallableTrainer implements Callable<PredictorResult> {
dataType data;
CallableTrainer( dataType massiveData ) {
this.data = massiveData;
}
@Override
public PredictorResult call() throws Exception {
// do something and return ...
}
}
Based on the above implementation, I assume that the 'massiveData' is always copied for each thread (right?) If this is true, I am wasting lots of memory by copying this data for each thread. Is there any way to share the data between threads?