# Unexpected behavior with multiple processors and @everywhere in for loop

**URL:** <https://discourse.julialang.org/t/unexpected-behavior-with-multiple-processors-and-everywhere-in-for-loop/24589>\
**Category:** General Usage\
**Created:** [May 24, 2019, 9:50pm UTC](https://discourse.julialang.org/t/unexpected-behavior-with-multiple-processors-and-everywhere-in-for-loop/24589 "2019-05-24T21:50:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![omalled](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/omalled/32/12532_2.png) [@omalled](https://discourse.julialang.org/u/omalled)\
**Post date:** [May 24, 2019, 9:50pm UTC](https://discourse.julialang.org/t/unexpected-behavior-with-multiple-processors-and-everywhere-in-for-loop/24589/1 "2019-05-24T21:50:04Z")

</div>

I’m running into an issue that I can’t wrap my head around. Here’s a MWE reduced from a more complex code:

```julia
i = 0
for j = 1:2
	global i
	i = j
	@show :before, myid(), i
	@everywhere i = remotecall_fetch(()->i, 1)
	@show :after, myid(), i
end
@show i

```

Case 1: start julia with `julia -p N` where `N` is at least 1, the output is

```julia
(:before, myid(), i) = (:before, 1, 1)
(:after, myid(), i) = (:after, 1, 1)
(:before, myid(), i) = (:before, 1, 2)
(:after, myid(), i) = (:after, 1, 1)
i = 1
1

```

Case 2: start julia with `julia` (i.e., without `-p N`), the output is

```julia
(:before, myid(), i) = (:before, 1, 1)
(:after, myid(), i) = (:after, 1, 1)
(:before, myid(), i) = (:before, 1, 2)
(:after, myid(), i) = (:after, 1, 2)
i = 2
2

```

The case 2 output is what I would expect to happen regardless of the number of processors. I don’t understand those last two outputs where `i=1` from case 1. Can anyone help me understand what is going on there? What am I missing? Is this a bug? Is this a feature?
