Getting multiple threads working in VS code, have changed envirinment settings.. no joy

I followed the guidance in a previous thread, which led me to the environment settings in VS code where I have changed the thread number to 4, for user and workspace. However, julia is apparently still using one thread. I have closed and reopened VS code, closed all the julia files in VS code, then closed and reopened VS code, but without anything improving. Settings shows 4 threads but Threads.nthreads() still shows 1.

Pretty sure I’m being stupid, can anyone help me!?

btw. I added this to the end of a previous forum thread a few days ago, but it was quite an old question, and as my query didn’t generate any responses, I thought I should probably post as a new question instead.

When you are running your test file, are you first opening the Julia REPL via the command palette in VSCode?

I actually had this same problem awhile ago. Initially I solved it by changing the environment variables within the terminal in VSCode (which was annoying to do every time). Then I figured out that if I started a Julia REPL with the command palette (ctrl + shift + p and search for julia) it would open with the number of threads specified in my VSC settings.

1 Like

I asked about this on Slack, and it appears that debugging (i.e. F5) only uses the default single thread and can’t be configured to use more because the launch configuration doesn’t take additional CLI args or environment variables. The easiest way to get around this is to use the REPL, either via the shortcut @bart816 mentioned, any of the “evaluate …” commands or the green arrow in the top right corner of the editor (not the one in the debug sidebar).

1 Like

Many thanks to both bart826 and ToucheSir, problem solved!
For other absolute beginners like me, I thought I’d just add some detail about how I followed the instructions above. Comments on any ways in which this is wrong or sub-optimal very welcome!

First, to get juia accessing more than one thread, in VS code, I clicked on the ‘extensions’ icon, then on the settings icon for julia, giving access to the setting determining the number of threads accessed by julia.

Next, to run my file… I used ctrl+shift+p to produce an input box, in which I typed ‘julia’, giving a long list of julia commands in a dropdown, scrolling down selected ‘start REPL’. REPL appears, yeay!
enter print(Threads.nthreads()) in REPL and finally get ‘4’ instead of ‘1’, again, yeay!

To run my file, I had the file open and selected in the editor, then ctrl+shift+p again, type julia and select ‘Execute File’, and … my file runs, yeay!!!

Next question will doubtless be about using multiple threads, now I have the option!

Once again many thanks for your help and support.