tdisjoint_slice1.nim 349 B

12345678910111213141516171819202122
  1. discard """
  2. outputsub: "EVEN 28"
  3. """
  4. import threadpool
  5. proc odd(a: int) = echo "ODD ", a
  6. proc even(a: int) = echo "EVEN ", a
  7. proc main() =
  8. var a: array[0..30, int]
  9. for i in low(a)..high(a): a[i] = i
  10. parallel:
  11. var i = 0
  12. while i <= 29:
  13. spawn even(a[i])
  14. spawn odd(a[i+1])
  15. inc i, 2
  16. # is correct here
  17. main()