Initial project import
This commit is contained in:
commit
23f2d29e32
11957 files changed
+1754577
No files matched your search
@@ -0,0 +1,18 @@
|
||||
import time
|
||||
|
||||
// Simulate expensive computing using sleep function
|
||||
fn expensive_computing(id int, duration int) {
|
||||
println('Executing expensive computing task (${id})...')
|
||||
time.sleep(duration * time.millisecond)
|
||||
println('Finish task ${id} on ${duration} ms')
|
||||
}
|
||||
|
||||
fn main() {
|
||||
mut threads := []thread{}
|
||||
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!')
|
||||
}
|
||||
Reference in new issue
Block a user