New in Wolfram Mathematica 7: Built-in Parallel Computing  previous | next 
Dynamically Display Load Balancing in a Parallel Computation
Shared variables synchronize their values between the master kernel and all the parallel subkernels. This is a convenient way to store a result or to report back progress on a computation. Using the shared variable in a Dynamic allows progress to be monitored as the computation runs.
In[1]:=

Click for copyable input
count = {};

Dynamic[data = GatherBy[count, First];

 data = Replace[data, {_, v_} -> v, {2}];

 Grid[Partition[Map[Histogram[#, 20] &, data], 3]]]
Out[1]=



In[2]:=

Click for copyable input
SetSharedVariable[result];

SetSharedVariable[count];

result = {};

ParallelDo[ 

  If[ PrimeQ[n! + 1], result = {result, n}];

  AppendTo[count, {$KernelID, n}];, {n, 1000}, 

  Method -> "FinestGrained"];