summary refs log tree commit diff stats
path: root/tests/gc/tthreads.nim
blob: 2ef599e5382e1ef14c3d0f901a43bad2a887c4c6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import threads

var
  thr: array [0..4, TThread]
  L: TLock
  
proc threadFunc(c: pointer) {.procvar.} = 
  for i in 0..9: 
    Aquire(L)
    echo i
    Release(L)

InitLock(L)

for i in 0..high(thr):
  createThread(thr[i], threadFunc)
for i in 0..high(thr):
  joinThread(thr[i])