Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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 thought of a possible answer to Monitor doesn't work with ParallelTable but it doesn't work as I hoped it would.

This accumulates print cells instead of deleting them as intended. Can it be fixed?

  NotebookDelete[x]; x = PrintTemporary[i];
  Pause[1]; i,
  {i, 1, 15}

I thought that x would be local to each kernel, and this would print four cells (for four cores) that would be deleted and replaced with each iteration.

I then thought that the value of x was lost between iterations, but this also fails to delete the print cells:

  x = PrintTemporary[i]; NotebookDelete[x];
  Pause[1]; i,
  {i, 1, 15}
share|improve this question
up vote 8 down vote accepted

This will display a list that's updated as long as the calculation runs, and vanishes afterwards:

(* Pattern that translates the kernel's ID to
   a number from 1 to $KernelCount *)
kernels = ParallelTable[$KernelID -> i, {i, $KernelCount}];
SetSharedVariable[kernels]; (* for Mathematica 7 *)

(* This is the list that will display each kernel's current operation *)
currentNumber = ConstantArray[0, Length@kernels];

PrintTemporary["Current calculations:"];

(* Start the computation *)
    Pause@RandomReal[{0, .25}]; (* Long calculation *)
    currentNumber[[$KernelID /. kernels]] = i,
    {i, 100},
    Method -> "FinestGrained"

The immediate output looks like this:

Current calculations:

{15, 24, 16, 23, 25, 29, 27, 20}

Now wait for ParallelTable to finish, and the above will disappear, leaving only the result:

{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ...}

You can modify the Dynamic statement according to your needs of course, such as adding a // Column to the argument to print it nicer etc.

share|improve this answer

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.