The example below is from Julia 1.3 manual (with some prints added)
@everywhere function count_heads(n)
c::Int = 0
for i = 1:n
c += rand(Bool)
end
c
end
a = @spawnat :any begin
@async Core.println("proc id=$(myid()), thread id=$(threadid())")
count_heads(100000000)
end
b = @spawnat :any begin
@async Core.println("proc id=$(myid()), thread id=$(threadid())")
count_heads(100000000)
end
fetch(a)+fetch(b)
The resulting output is this:
From worker 3: proc id=3, thread id=1
From worker 2: proc id=2, thread id=1
Which, I think, shows that a and b are calculated in a different process space and also shows that they are calculated by the same thread (id==1) so by the same physical core. This seems not true parallel computing. Or where is my understanding wrong?