v / examples / concurrency
Raw file | 13 loc (12 sloc) | 239 bytes | Latest commit hash 017ace6ea
1fn expensive_computing(i int) int {
2 return i * i
3}
4
5fn main() {
6 mut threads := []thread int{}
7 for i in 1 .. 10 {
8 threads << spawn expensive_computing(i)
9 }
10 // Join all tasks
11 r := threads.wait()
12 println('All jobs finished: ${r}')
13}