First Case: Lets say you have a lot of tasks that all return a result of some kind, lets just call it `result' for now, and these all have to be stored in an arraylist. There's two options:
1) Create one arraylist in the main method and use runnables with access to the shared list and a synchronized add method
2) Create one arraylist in the main method and use callable to perform the task and return the result and let the main method add the Result to its list.
Are there any performance differences between the two, seeing as the runnable need synchronized acces, but the callables do not?
Then, to the Second Case: Lets now say each tasks generates a `small' arraylist, lets say less than 10 items per task. This again gives two options:
1) One arraylist in main and runnables with access to the shared list that add result items whenever generated.
2) One arrayList in main and callables> with each their own local arraylist that stores the Results untill the task is finished and then in main the addAll is used to add the found result.
Same question as before, what are the performance difference?
For the sake of clearity, performance both in terms of speed (some synchronization issues etc.) and in terms of memory(do the callables use a lot more memory due to the local small arraylist or is this small to neglible)?