Skip to content

Instantly share code, notes, and snippets.

@Ken-Kuroki
Created March 3, 2020 16:39
Show Gist options
  • Save Ken-Kuroki/9741bffe3df49305a43fb16c7de32fb1 to your computer and use it in GitHub Desktop.
Save Ken-Kuroki/9741bffe3df49305a43fb16c7de32fb1 to your computer and use it in GitHub Desktop.
Julia multithreads
# Check nthreads() is large enough
println(Threads.nthreads())
function f(input)
return input*2
end
function main()
inputs = [i for i in 20:30];
outputs = zeros(10);
Threads.@threads for i in 1:10
output[i] = f(inputs[i]);
end
end
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment