Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to parallelize my script. Here is a MWE of how I have done it:


container = {};

fun[x_] := 2*x;
container = ParallelTable[{i, fun[i]}, {i, 1, 3}];

I am unsure if this is done correctly. There are mainly two things I am concerned about when using ParallelTable:

  1. Is it necessary to parallelize the expression to be looped, i.e. fun?
  2. Is it necessary to make the container with the ParallelTable-results a shared variable?
share|improve this question
1. I believe in the most recent versions not necessary 2. No, don't do it as you did. This is only necessary for variables that you want to have shared during the parallel calculations. – Sjoerd C. de Vries Jun 3 '13 at 21:29
@SjoerdC.deVries Adding to 1. From the documentation: "The default value is DistributedContexts:>$DistributedContexts with $DistributedContexts:=$Context, which distributes definitions of all symbols in the current context, but does not distribute definitions of symbols from packages." So you are right! – sebhofer Jun 4 '13 at 9:22

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.