Figured out why future crashed, added in simple threading library. Future isn't fixed yet, but could be with a similar approach
This commit is contained in:
5
tests/test_thread.expected_results
Normal file
5
tests/test_thread.expected_results
Normal file
@@ -0,0 +1,5 @@
|
||||
hello from main first
|
||||
hello from thread first 1347
|
||||
hello from main middle
|
||||
hello from thread second 1347
|
||||
hello from main after join
|
||||
20
tests/test_thread.krak
Normal file
20
tests/test_thread.krak
Normal file
@@ -0,0 +1,20 @@
|
||||
import io:*
|
||||
import os:*
|
||||
import thread:*
|
||||
|
||||
fun main(): int {
|
||||
var a = 1337
|
||||
println("hello from main first");
|
||||
var t = run(fun(l: int) {
|
||||
print("hello from thread first ")
|
||||
println(a+l)
|
||||
system("sleep 2")
|
||||
print("hello from thread second ")
|
||||
println(a+l)
|
||||
}, 10)
|
||||
system("sleep 1")
|
||||
println("hello from main middle");
|
||||
join(t)
|
||||
println("hello from main after join");
|
||||
return 0
|
||||
}
|
||||
Reference in New Issue
Block a user