mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
fmt: replace go
with spawn
This commit is contained in:
@ -9,9 +9,9 @@ fn expensive_computing(id int, duration int) {
|
||||
|
||||
fn main() {
|
||||
mut threads := []thread{}
|
||||
threads << go expensive_computing(1, 100)
|
||||
threads << go expensive_computing(2, 500)
|
||||
threads << go expensive_computing(3, 1000)
|
||||
threads << spawn expensive_computing(1, 100)
|
||||
threads << spawn expensive_computing(2, 500)
|
||||
threads << spawn expensive_computing(3, 1000)
|
||||
// Join all tasks
|
||||
threads.wait()
|
||||
println('All jobs finished!')
|
||||
|
@ -26,7 +26,7 @@ fn main() {
|
||||
mut wg := sync.new_waitgroup()
|
||||
wg.add(2)
|
||||
// Run tasks async
|
||||
go vlang_time(mut wg)
|
||||
go remote_ip(mut wg)
|
||||
spawn vlang_time(mut wg)
|
||||
spawn remote_ip(mut wg)
|
||||
wg.wait()
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ fn expensive_computing(i int) int {
|
||||
fn main() {
|
||||
mut threads := []thread int{}
|
||||
for i in 1 .. 10 {
|
||||
threads << go expensive_computing(i)
|
||||
threads << spawn expensive_computing(i)
|
||||
}
|
||||
// Join all tasks
|
||||
r := threads.wait()
|
||||
|
Reference in New Issue
Block a user