Tin

Examples · learn/21-concurrency · 252 of 339

stop

examples/learn/21-concurrency/stop.tintin run examples/learn/21-concurrency/stop.tin
fn job(): string {
  print("job started")
  sleep(1h)                 // a long wait: the task pauses here
  print("never printed")
  "done"
}

fn main() {
  let t = spawn job()
  sleep(10ms)
  t.stop()                  // stops the task (and anything it started) at its pause
  print("stopped it")
}