summary refs log tree commit diff stats
path: root/tests/threads/tmanyjoin.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/threads/tmanyjoin.nim')
-rw-r--r--tests/threads/tmanyjoin.nim31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/threads/tmanyjoin.nim b/tests/threads/tmanyjoin.nim
new file mode 100644
index 000000000..af5bc460e
--- /dev/null
+++ b/tests/threads/tmanyjoin.nim
@@ -0,0 +1,31 @@
+discard """
+  disabled: i386
+  outputsub: "129"
+"""
+
+import os, locks
+
+type
+  MarkerObj = object
+    lock: Lock
+    counter: int
+  Marker = ptr MarkerObj
+
+const
+  ThreadsCount = 129
+  SleepTime = 250
+
+proc worker(p: Marker) {.thread.} =
+  acquire(p.lock)
+  inc(p.counter)
+  release(p.lock)
+  sleep(SleepTime)
+
+var p = cast[Marker](allocShared0(sizeof(MarkerObj)))
+initLock(p.lock)
+var ts = newSeq[Thread[Marker]](ThreadsCount)
+for i in 0..<ts.len:
+  createThread(ts[i], worker, p)
+
+joinThreads(ts)
+echo p.counter