diff options
Diffstat (limited to 'tests/threads/threadex.nim')
-rw-r--r-- | tests/threads/threadex.nim | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/tests/threads/threadex.nim b/tests/threads/threadex.nim index 442e80189..fb03cbfa8 100644 --- a/tests/threads/threadex.nim +++ b/tests/threads/threadex.nim @@ -14,8 +14,11 @@ var producer, consumer: Thread[void] chan: Channel[TMsg] printedLines = 0 + prodId: int + consId: int proc consume() {.thread.} = + consId = getThreadId() while true: var x = recv(chan) if x.k == mEof: break @@ -23,6 +26,7 @@ proc consume() {.thread.} = atomicInc(printedLines) proc produce() {.thread.} = + prodId = getThreadId() var m: TMsg var input = open("readme.txt") var line = "" @@ -40,5 +44,6 @@ joinThread(consumer) joinThread(producer) close(chan) +doAssert prodId != consId echo printedLines |