tsysspawn.nim 315 B

1234567891011121314151617181920212223242526272829303132
  1. discard """
  2. output: '''4
  3. 8'''
  4. cmd: "nim $target --threads:on $options $file"
  5. """
  6. import threadpool
  7. var
  8. x, y = 0
  9. proc p1 =
  10. for i in 0 .. 10_000:
  11. discard
  12. atomicInc x
  13. proc p2 =
  14. for i in 0 .. 10_000:
  15. discard
  16. atomicInc y, 2
  17. for i in 0.. 3:
  18. spawn(p1())
  19. spawn(p2())
  20. sync()
  21. echo x
  22. echo y