Trying to make multithreading to work on applying a function number of times

You are almost there.

Unfortunately, the use of Threads.threadid() is no longer recommended due to the dynamical scheduling mechanisms that Threads.@threads offers.

You can read more about here PSA: Thread-local state is no longer recommended; Common misconceptions about threadid() and nthreads().


To get the version you have working, you have to update the for loop to read

Threads.@threads :static for i in 1:50

However, as the blog post explains this is also not longer recommended and one should use the advises given there.

1 Like