# @threads tasks and Jupyter interrupt kernel

**URL:** <https://discourse.julialang.org/t/threads-tasks-and-jupyter-interrupt-kernel/55307>\
**Category:** General Usage\
**Tags:** jupyter, multithreading\
**Created:** [February 15, 2021, 11:04am UTC](https://discourse.julialang.org/t/threads-tasks-and-jupyter-interrupt-kernel/55307 "2021-02-15T11:04:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dnadlinger](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnadlinger/32/7632_2.png) [@dnadlinger](https://discourse.julialang.org/u/dnadlinger)\
**Post date:** [February 15, 2021, 11:04am UTC](https://discourse.julialang.org/t/threads-tasks-and-jupyter-interrupt-kernel/55307/1 "2021-02-15T11:04:08Z")

</div>

I am using Julia inside Jupyter (using IJulia.jl), and have some computationally intensive tasks distributed over several threads using a `Threads.@threads` for loop.

Interrupting the kernel more often than not only seems to interrupt the computation for those loop indices scheduled on the main thread; the other threads continue execution. (I’m not sure if this is deterministic or not.)

This is an issue for obvious reasons – not only does it waste CPU time, the additional threads being busy with old tasks means any new `@threads` loops will hang at 25% completion waiting for the old tasks to complete, as the indices are partitioned statically.

How can I make sure interruptions work reliably – that is, I would think, an InterruptException is injected on all the threads? (The fact that this doesn’t work out of the box is a bug report for at least one part of the stack, but at the moment, I’m not sure which one.)
