Examples · learn/21-concurrency · 252 of 339
stop
tin run examples/learn/21-concurrency/stop.tinfn 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")
}