How to kill thread?

According to @jameson, schedule(..., error=true) is not the correct way to terminate the task already started and there is no way to safely interrupt a task. Stop/terminate a (sub)task started with @async - #8 by jameson

First of all, you don’t need to use thread to run I/O concurrently. @async is enough. Also, for running external processes concurrently, you don’t even need to use @async:

julia> proc = run(`sleep 60`; wait = false)
Process(`sleep 60`, ProcessRunning)

julia> kill(proc)

julia> proc
Process(`sleep 60`, ProcessSignaled(15))
5 Likes