v2 / examples / concurrency / concurrency_returns.v
13 lines · 12 sloc · 239 bytes · 017ace6ea7402430a992aa0820d5e472ebca74c7
Raw
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}
14