To pass multiple arguments to a thread you need to wrap them in a tuple:
    
    
    import std/locks
    
    var
      L: Lock
    
    var x = 0
    
    proc threadFunc(a, b: int) {.thread.} =
      acquire(L) # lock stdout
      x.inc(a)
      echo b
      release(L)
    
    
    proc doIt() =
      initLock(L)
      var thr: array[0..4, Thread[int]]
      for i in 0..high(thr):
        createThread(thr[i], threadFunc, (i, i*i))
      joinThreads(thr)
      
      deinitLock(L)
    
    doIt()
    echo x
    
    
    Run

That being said working on a global `seq[seq[T]]` sounds like it could be 
trouble. At least it used to be trouble pre-ARC, not sure if it is any longer.

Reply via email to