# SharedArray with mixed types of elements? Alternative functions?

**URL:** <https://discourse.julialang.org/t/sharedarray-with-mixed-types-of-elements-alternative-functions/39316>\
**Category:** General Usage\
**Tags:** question\
**Created:** [May 12, 2020, 1:44am UTC](https://discourse.julialang.org/t/sharedarray-with-mixed-types-of-elements-alternative-functions/39316 "2020-05-12T01:44:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jing\_Zhang](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jing_zhang/32/13737_2.png) [@Jing\_Zhang](https://discourse.julialang.org/u/Jing_Zhang)\
**Post date:** [May 12, 2020, 1:44am UTC](https://discourse.julialang.org/t/sharedarray-with-mixed-types-of-elements-alternative-functions/39316/1 "2020-05-12T01:44:44Z")

</div>

Hi Julia users,

I am doing parallel computation using @distributed. The returned results will be a multi-dimensional array with mixed types of elements, such as Int64, Float64 and Spring. I was trying to use `SharedArray{Any}(...)` but `Any` doesn’t work here.

Any function works similarly to `SharedArray`?

Thanks a lot.

---

<div class="post-metadata">

**Author:** ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)\
**Post date:** [May 12, 2020, 1:48am UTC](https://discourse.julialang.org/t/sharedarray-with-mixed-types-of-elements-alternative-functions/39316/2 "2020-05-12T01:48:50Z")

</div>

I highly recommend using multithreading instead if it’s all on the same computer. Every array is “like” a shared array if you’re using multithreading (all threads can read/write, but just like a SharedArray beware of race conditions).

---

<div class="post-metadata">

**Author:** ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)\
**Post date:** [May 12, 2020, 1:50am UTC](https://discourse.julialang.org/t/sharedarray-with-mixed-types-of-elements-alternative-functions/39316/3 "2020-05-12T01:50:57Z")

</div>

Also, using a multidimensional Array with eltype `Any` strongly suggests that you should take a step back and consider using something like a vector of structs or something that better expresses your computation. The result of doing so will likely be a program that executes much more quickly. I think that rather than focusing on how to distribute `do_one` it is probably a really good idea to first post what `do_one` does (or a simplified version).
