1
$\begingroup$

People seem to suggest that one needs to start a new kernel to keep multiple Mathematica (MMA) notebooks independent e.g. Kernel management link. But I did not do so and still found my two notebooks running independently.

I opened the first notebook and entered

x=2;

Then, in the second notebook, I entered

x+1

and it gave me

1+x

instead of '3' thereby indicating that the two notebooks are independent. When I go to 'Evaluation >> Quit Kernel', I find only one option 'Local' in both the notebooks indicating that both notebooks are using the same kernel 'Local'.

So, how can multiple notebooks run independently despite being on the same kernel?

enter image description here

$\endgroup$

closed as off-topic by Szabolcs, MarcoB, m_goldberg, Edmund, bbgodfrey Jun 12 at 1:18

This question appears to be off-topic. The users who voted to close gave these specific reasons:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – m_goldberg, Edmund, bbgodfrey
  • "This question cannot be answered without additional information. Questions on problems in code must describe the specific problem and include valid code to reproduce it. Any data used for programming examples should be embedded in the question or code to generate the (fake) data must be included." – Szabolcs, MarcoB
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 6
    $\begingroup$ Are you looking for the CellContext "Notebook" setting in the Option Inspector window, which you can reach via the Advanced Preferences in the Preferences panel? Beware that while this splits context between notebooks, it doesn't mean you can execute code in one notebook while the other is doing stuff (like a long-running command) $\endgroup$ – Carl Lange Jun 5 at 14:01
  • 4
    $\begingroup$ How are you opening your two notebooks? Could it be that you're really running two instances of the Front-End, which a separate "Local" kernel each? You can check the context setting as suggested by @CarlLange (you can also evaluate $Context in both notebooks and see whether it's the same), and you could start a computation in one notebook (like Pause[15]), and try to evaluate something in the second while this is still running (as @CarlLange said, the second evaluation should be blocked if it's the same kernel for both notebooks). $\endgroup$ – Lukas Lang Jun 5 at 17:20
  • $\begingroup$ Did you set Evaluation -> Notebook's Default Context -> Unique to this notebook? $\endgroup$ – Szabolcs Jun 6 at 17:38
  • 3
    $\begingroup$ Lukas is right: it looks like you are running two separate instances of Mathematica. How do you know it's the same kernel? Did you check $ProcessID? $\endgroup$ – Szabolcs Jun 7 at 6:54
  • $\begingroup$ Yes, I was running two separate instances of MMA. $ProcessID showed two different numbers. Only when I start a new notebook by File>>New Notebook, the notebooks share the same variable name and the notebooks show the same ProcessID which was not the case for my above question. Thank you all. $\endgroup$ – Sashwat Tanay Jun 7 at 15:58