# Hi all I have this piece of multithreaded code, however it is only executing the f

**URL:** <https://discourse.julialang.org/t/hi-all-i-have-this-piece-of-multithreaded-code-however-it-is-only-executing-the-f/55878>\
**Category:** General Usage\
**Created:** [February 23, 2021, 7:13pm UTC](https://discourse.julialang.org/t/hi-all-i-have-this-piece-of-multithreaded-code-however-it-is-only-executing-the-f/55878 "2021-02-23T19:13:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![BridgeBot](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bridgebot/32/21491_2.png) [@BridgeBot](https://discourse.julialang.org/u/BridgeBot)\
**Post date:** [February 23, 2021, 7:13pm UTC](https://discourse.julialang.org/t/hi-all-i-have-this-piece-of-multithreaded-code-however-it-is-only-executing-the-f/55878/1 "2021-02-23T19:13:41Z")

</div>

Hi all I have this piece of multithreaded code, however it is only executing the first queue in \_queues. Could anyone give any pointer 🙂 ?

```julia
function execute_queues!()
    @async begin
        amqp_connection!(_conn_def) do conn
            amqp_channel!(conn) do chan
                @sync for queue in _queues
                    @async Threads.@spawn queue(chan)
                end
            end
        end
    end
end

```

Note that the original poster on Slack cannot see your response here on Discourse. Consider _transcribing the appropriate answer back to Slack_, or pinging the poster here on Discourse so they can _follow this thread_.  
[(Original message :slack:)](https://julialang.slack.com/archives/C6A044SQH/p1614107251219900?thread_ts=1614107251.219900&cid=C6A044SQH) [(More Info)](https://github.com/JuliaCommunity/SlackBridge)

---

<div class="post-metadata">

**Author:** ![pbayer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pbayer/32/11675_2.png) [@pbayer](https://discourse.julialang.org/u/pbayer)\
**Post date:** [February 23, 2021, 8:33pm UTC](https://discourse.julialang.org/t/hi-all-i-have-this-piece-of-multithreaded-code-however-it-is-only-executing-the-f/55878/2 "2021-02-23T20:33:57Z")

</div>

without knowing what you do with `amqp_connection!` and `amqp_channel!` and `_queue` … but you in that function

1. start an `@async` task that
2. starts a for loop starting `@async` tasks each of which
3. `@spawns` a task …

so you can – for debugging – try first without the two `@async` calls (you can reintroduce them later) and return a `Vector{Task}`, which then you can look at, something like that:

```julia
function execute_queues!()
    ts = Task[]
    amqp_connection!(_conn_def) do conn
        amqp_channel!(conn) do chan
            @sync for queue in _queues
                push!(ts, Threads.@spawn queue(chan))
            end
        end
    end
    return ts
end

```

This should show you if any of the spawned tasks have failed and eventually you can look at their stack traces.
