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:
Nathan Braswell
2016-06-11 11:27:48 -07:00
parent 2c8c3af48a
commit 1318e71efd
3 changed files with 76 additions and 0 deletions

View 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
View 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
}