RosettaCodeData/Task/Concurrent-computing/Nim/concurrent-computing-1.nim

11 lines
195 B
Nim
Raw Permalink Normal View History

2016-12-05 23:44:36 +01:00
const str = ["Enjoy", "Rosetta", "Code"]
2017-09-23 10:01:46 +02:00
var thr: array[3, Thread[int32]]
2016-12-05 23:44:36 +01:00
2017-09-23 10:01:46 +02:00
proc f(i:int32) {.thread.} =
2016-12-05 23:44:36 +01:00
echo str[i]
for i in 0..thr.high:
createThread(thr[i], f, int32(i))
joinThreads(thr)