# Parallel kernel and front end

I have a piece of code which looks like this:

ParallelTable[

Monitor[
Table[
<code here>
,{i,i1,i2];
,i];

]


so basically a Table which I parallelize. Each element of this parallelized table being itself a Table which I want to monitor.

I receive this error message:

FrontEndObject::notavail: A front end is not available; certain operations require a front end.

This error originates from the Monitor[]. I suspect that because my first Table is parallelized, somehow the dynamic cell into which Monitor[] will write to is not connected to any Front End or something...

How would I solve this issue?

• What happened when you started a front end? – Oleksandr R. Jul 3 '14 at 10:49
• from help, it says: generates a monitor cell that shows the continually updated current value...In a notebook, the monitor cell normally appears directly after the cell in which Monitor[expr,mon] is evaluated so clearly Monitor requires a frontend. Can't be used in script/batch. – Nasser Jul 3 '14 at 11:28
• @OleksandrR. Can you start a front end for each parallel kernel and use Monitor? – acl Jul 3 '14 at 11:46
• In case it is not clear, I have a Front End running for my master kernel. How would I start a Front End for each child kernels ? – coussin Jul 3 '14 at 13:22
• Or rather, each child kernels should use the Front End used by my master kernel... – coussin Jul 3 '14 at 13:33

As pointed in the comments by @Nasser, Monitor needs a front end, so it should be outside ParallelTable. It also needs a variable that acts as a "counter" and that is shared among all the kernels participating in the calculation, for that you can use SetSharedVariable. Therefore, a solution to your question would be:

SetSharedVariable[iter]
iter = 0
Monitor[
ParallelTable[
iter += 1;
FactorInteger[999999999]
, {1000}
], ProgressIndicator[iter, {0, 1000}]];


Its is true that its questionable if the cost of keeping the iteration counter updated makes parallelism worthwhile, as pointed by @mfvonh. This should be evaluated case by case, and its not impossible that its advantageous. I have found this trick useful at least once.