summary refs log tree commit diff stats
path: root/tests/niminaction/Chapter6/WikipediaStats/race_condition.nim
blob: f4b072204361106187704441a9b29d6cd09b18a7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
discard """
action: compile
"""

import threadpool

var counter = 0

proc increment(x: int) =
  for i in 0 ..< x:
    let value = counter + 1
    counter = value

spawn increment(10_000)
spawn increment(10_000)
sync()
echo(counter)