title: how to kill a task in Julia?
body: <p>I have a Julia code where I need to execute two operation in a parallel way.
  My problem is that I need to stop and kill one operation if it take too much time.</p>
  
  <p>I tried with the <code>Task</code> but now I can't find how to kill a task. My code is:</p>
  
  <pre><code>function mytask(myargs, ch)
      # do some work (optimize a problem with Gurobi)
      # that can go on for a very long time
      put!(ch, computationResult)
  end
  
  ch = Channel(1)
  task = @async mytask(args, ch)
  
  # now the main task does some other work
  # and at the end
  
  if isready(ch)
      taskResult = take!(ch)
  else
      # the result of th async task became useless
      # so here I need to kill the async task
  end
  
  # continue the execution
  </code></pre>
  
  <p>I found this <a href="https://stackoverflow.com/questions/27209663/how-do-i-kill-a-task-coroutine-in-julia">similar old question</a> but I think the solution is no longer supported because I can't find the <code>throwto</code> method in the documentation and I also tried it but I get this error message</p>
  
  <pre><code>WARNING: Workqueue inconsistency detected: shift!(Workqueue).state != :queued
  ERROR (unhandled task failure): InterruptException:
  </code></pre>
  
  <p>I'm not forced to use tasks, I can use thread processes or any other solution as long as it works</p>