t5000.nim 361 B

1234567891011121314151617181920212223242526
  1. discard """
  2. output: '''50005000'''
  3. disabled: "true"
  4. """
  5. # XXX this seems to deadlock certain Linux machines
  6. import threadpool, strutils
  7. proc foo(x: int): string = $x
  8. proc main() =
  9. var a = newSeq[int]()
  10. for i in 1..10000:
  11. add(a, i)
  12. var s = 0
  13. for i in a:
  14. s += parseInt(^spawn(foo(i)))
  15. echo s
  16. setMaxPoolSize 2
  17. parallel:
  18. spawn main()