Hi all, hoping someone here can help me answer a MultiThreaded problem I am having.

Here is my code:

```
n = 10000000;
numprimes = Threads.Atomic{Int}(0);
function is_prime(n)
if n == 0 | n == 1
return 0
elseif n == 2
return 1
end
root_n = isqrt(n)
for i = 2:root_n
if n%i == 0
return 0
end
end
return 1
end
function main()
Threads.@threads for i = 1:n
if is_prime(i) == 1
global numprimes = atomic_add!(numprimes, 1)
end
end
end
main()
```

I am getting this error when trying to use a Threads.@Atomic variable to collect `numprimes`

:

```
Error thrown in threaded loop on thread 0: MethodError(f=typeof(Base.:(+))(), args=(Base.Threads.Atomic{Int64}(value=0), 1), world=0x00000000000063ec)Thread ID:
1
```

And I can’t find something online to help me figure out how to solve this.

Would anyone have some insight on what I should change in my code?

Many thanks!