On Oct 11, 2016 12:34 PM, "Evan Fields" <evanjeromefie...@gmail.com> wrote:
>
> Let's say I have a type MyType and function f(mt::MyType) which is slow
and stochastic. I have an object y::MyType, and I'd like to compute f(y)
many times.
>
> If I write a loop like
> fvals = Vector{Float64}(100)
> Threads.@threads for i in 1:length(fvals)
>   ycopy = deepcopy(y)
>   fvals[i] = f(ycopy)
> end
>
> The various loop iterations are not interfering with each other, right?
Each has its own copy of y?

Normal variables have the same scope behavior as a normal loops so they are
bit shared if it is not used outside the loop.

Reply via email to