I feel this question probably has been asked before, but I can't find a thread with a clear enough answer. Let me know if you can help locate anything useful.
As the title suggests, I want to run different calculations at the same time. Typically, we have program A running now, which will last for hours. In the meantime, I need to calculate B, maybe a different version of A or some completely different stuff. How to start B completely independently from A?
Firstly, a new notebook doesn't help. It only waits until A finishes. This is probably the main question.
Secondly, by 'independently', I mean if A and B happen to have certain same variable names or so, surely we want to avoid any possible side effects. And I usually start my programs with ClearAll["Global`*"];
. But running B had better not clean anything in A. In this sense, maybe this command is no longer a good practice?
(Optional) Thirdly, with parallelization. If A uses 2 cores and B uses another 2 cores, is the above still possible?
I remember that one can open a new instance of MMA in Windows, but this doesn't seem available in Mac.
Module
. With this you can treat your variables insideModule
as local and they won't be defined outside it. $\endgroup$ParallelSubmit
to do the trick. $\endgroup$ClearAll["Global
*"];` is indeed not a good practice in general. As rowsi suggests, get into the habit of localizing variables withModule
,Block
, orWith
in greater projects. $\endgroup$Evaluation
menu. Add a kernel there, and assign it to a new notebook. $\endgroup$