iTranslated by AI
Using Multi-threading for Julia in Jupyter
As described here, you can use thread parallelism by starting Julia with julia -t 4 or julia -t auto, but how do you use thread parallelism in Jupyter Notebook/Lab? The IJulia.jl kernel is single-threaded by default, so if you want to use multi-threading, you need to add a kernel using the following method.
Installing IJulia.jl
If you haven't installed Jupyter Notebook/Lab yet, add IJulia.jl with import Pkg; Pkg.add("IJulia"). Detailed steps are explained in the article below.
Adding a Multi-threaded Kernel
I forget where I first saw this idea, but searching online leads to the same code on this page. You can automatically add a Julia kernel with the maximum number of threads specified using the command below. If you want to specify a specific number of threads, please refer to this page.
using IJulia
installkernel("Julia (Multi-threads)", "--threads=auto")
After adding it, start Jupyter Lab as usual.
using IJulia; jupyterlab(detached=true)
You can confirm that the parallelized kernel has been added.

You can check the number of threads as follows.
Threads.nthreads()

Application Example
I have prepared an example where thread parallelism actually improves speed. Many researchers have developed fast solvers for matrix eigenvalue problems, but since we need to handle the matrix construction ourselves, examples like the one below are helpful.
Discussion