# Why Pmap() skipping a combination in the function arguments

**URL:** <https://discourse.julialang.org/t/why-pmap-skipping-a-combination-in-the-function-arguments/38152>\
**Category:** New to Julia\
**Tags:** question, parallel, pmap\
**Created:** [April 24, 2020, 3:11pm UTC](https://discourse.julialang.org/t/why-pmap-skipping-a-combination-in-the-function-arguments/38152 "2020-04-24T15:11:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Saptarshi\_Ghosh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/saptarshi_ghosh/32/14300_2.png) [@Saptarshi\_Ghosh](https://discourse.julialang.org/u/Saptarshi_Ghosh)\
**Post date:** [April 24, 2020, 3:11pm UTC](https://discourse.julialang.org/t/why-pmap-skipping-a-combination-in-the-function-arguments/38152/1 "2020-04-24T15:11:10Z")

</div>

Hi! I am new to Julia and wondering about a simple implementation of the julia pmap function. Here is the sample code

```nohighlight
using Distributed; addprocs(6) #adding workers

io = open("myfile.txt", "w"); write(io, "This is a test!\n"); close(io);

@everywhere function writing_test(a,b)
    io = open("myfile.txt", "a");
    r=string(a,"\t",b,"\n")
    write(io,r);
    close(io);
end

pmap(writing_test,20:30,220:230) #Calling the Function through pmap
for i in workers(); rmprocs(i); end #Removing Workers

```

And here is the output of myfile.txt

```julia
This is a test!
22	222
24	224
26	226
27	227
28	228
29	229
30	230
20	220

```

I am wondering why 21 221 combination is missing. Is it random that one of the combination is missing from such implementation?

---

<div class="post-metadata">

**Author:** ![hendri54](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hendri54/32/9621_2.png) [@hendri54](https://discourse.julialang.org/u/hendri54)\
**Post date:** [April 25, 2020, 12:12pm UTC](https://discourse.julialang.org/t/why-pmap-skipping-a-combination-in-the-function-arguments/38152/2 "2020-04-25T12:12:13Z")

</div>

Possibly a race condition where multiple processes try to write to the same file at the same time. I would try to lock the file around the write operation. See [Multi-Threading · The Julia Language](https://docs.julialang.org/en/v1/base/multi-threading/#Base.Threads.SpinLock)
