# \`eval\` scope problem and \`println\` problem for multithreading

**URL:** <https://discourse.julialang.org/t/eval-scope-problem-and-println-problem-for-multithreading/109333>\
**Category:** General Usage\
**Tags:** question, multithreading, eval, sockets\
**Created:** [January 27, 2024, 9:26am UTC](https://discourse.julialang.org/t/eval-scope-problem-and-println-problem-for-multithreading/109333 "2024-01-27T09:26:39Z")\
**Posts on this page:** 1\
**Showing post:** 13

<div class="post-metadata">

**Author:** ![Benny](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@Benny](https://discourse.julialang.org/u/Benny)\
**Post date:** [January 28, 2024, 9:00am UTC](https://discourse.julialang.org/t/eval-scope-problem-and-println-problem-for-multithreading/109333/13 "2024-01-28T09:00:53Z")

</div>

I don’t think it’s `println`’s nested locks causing “aa” not to be printed at all; locking would affect task printing order. It’s just your [script’s primary task ending and closing the process](https://stackoverflow.com/questions/34027380/julia-async-block-couldnt-get-any-result-with-command-prompt) when your `@async` task yielded control midway. That’s just something you always need to account for when you run a script from the command line. I think enclosing the tasks in [`@sync begin ... end`](https://docs.julialang.org/en/v1/base/parallel/#Base.@sync) would work as well as `wait`, and it’s more convenient to do once over multiple tasks.

---

_[View the full topic](https://discourse.julialang.org/t/eval-scope-problem-and-println-problem-for-multithreading/109333)._
