summary refs log blame commit diff stats
path: root/tests/niminaction/Chapter6/WikipediaStats/race_condition.nim
blob: c62b2f93eb21814bc2590176a33b1c7f772b1bfd (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13












                           
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)