I usually use a combination of @spawn and fetch. @spawn fires a lightweigth task that can return a value of any type, which can be collected by the main thread with fetch:
refs = Vector{RemoteRef}(N) for i in 1:N refs[i] = @spawn begin doSomethingAndReturnValueOfTypeT end end for i in 1:N v[i] = fetch(refs[i]) end I'm not aware if there is a better way, as far as I know SharedArrays don't work with user-defined types. You need to have worker threads for this to be of any use, by using addprocs() or by starting julia with the -p flag, for instance $ julia -p 4. I hope that helps, Germán. On Friday, September 9, 2016 at 7:51:59 AM UTC-3, ami...@gmail.com wrote: > > Hello, > > What would be the best option to parallelize this code: > > type T a end > f(i) = T(i) > v = map(f, collect(1:1:100)) > > This example could sound stupid but the point is that I have a function > ```f``` that returns a rather complicated user-defined type ```T```, and I > need to store a lot of these types in an ```Array```. > I've read a bit about the parallel paradigm of Julia and I honestly > wouldn't know how to do such a thing. > > Any hint? > > Many thanks! >