# Calling pmap from thread hangs

**URL:** https://discourse.julialang.org/t/calling-pmap-from-thread-hangs/41012
**Category:** New to Julia
**Created:** [June 8, 2020, 6:54pm UTC](https://discourse.julialang.org/t/calling-pmap-from-thread-hangs/41012 "2020-06-08T18:54:15Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![samuel\_okon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/samuel_okon/32/10285_2.png) [@samuel\_okon](https://discourse.julialang.org/u/samuel_okon)
#### Post date: [June 8, 2020, 6:54pm UTC](https://discourse.julialang.org/t/calling-pmap-from-thread-hangs/41012/1 "2020-06-08T18:54:15Z")

</div>

Hi, for some reason the code snippet below hangs. Does any one have an explanation as to why this hangs

```julia
using distributed
addprocs(2)
tasks = Vector{Task}(undef,4)
@sync for i in 1:4
       tasks[i] = Threads.@spawn begin
           pmap(x->x, WorkerPool(workers()), 1:10)
       end
end
fetch.(tasks)

```

Surprisingly if i first run `pmap(x->x, WorkerPool(workers()), 1:10)` before running the code above everything works as expected.
