# SharedArray of custom types

**URL:** <https://discourse.julialang.org/t/sharedarray-of-custom-types/6802>\
**Category:** General Usage\
**Created:** [October 31, 2017, 1:32pm UTC](https://discourse.julialang.org/t/sharedarray-of-custom-types/6802 "2017-10-31T13:32:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mathtd](https://avatars.discourse-cdn.com/v4/letter/m/b487fb/32.png) [@mathtd](https://discourse.julialang.org/u/mathtd)\
**Post date:** [October 31, 2017, 1:32pm UTC](https://discourse.julialang.org/t/sharedarray-of-custom-types/6802/1 "2017-10-31T13:32:55Z")

</div>

Is there anyway to create SharedArray of some custom Type?

I.e. I would like to do the following

```julia
Type Foo
    a::Int64
end

b = SharedArray{Foo,2}((2))

b[2].a = 3

```

---

<div class="post-metadata">

**Author:** ![mauro3](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mauro3/32/292_2.png) [@mauro3](https://discourse.julialang.org/u/mauro3)\
**Post date:** [October 31, 2017, 1:37pm UTC](https://discourse.julialang.org/t/sharedarray-of-custom-types/6802/2 "2017-10-31T13:37:22Z")

</div>

Eltype of shared arrays need to be `isbits`. This works:

```julia
julia> struct Foo
           a::Int64
       end

       b = SharedArray{Foo,1}((2,))
       
       b[2] = Foo(3)                                                                                                                                                     
Foo(3)                                                                                                                                                                   

julia> b                                                                                                                                                                 
2-element SharedArray{Foo,1}:                                                                                                                                            
 Foo(0)                                                                                                                                                                  
 Foo(3)                                                                                                                                                                  

```
