The more I try things, the more I'm confused. Even this example, without any 
ref, does not work:
    
    
    import locks
    import os
    
    var s: string
    var c: int
    var l: Lock
    
    proc myFunc() {.thread.} =
        for i in 0..<50:
            os.sleep(1)
            {.gcsafe.}:
                withLock l:
                    echo "S = ",s
                    s.add($c)
                    s &= " "
                    inc c
    
    initLock(l)
    var thr: array[5, Thread[void]]
    for i in 0..4:
        createThread(thr[i], myFunc)
    joinThreads(thr)
    echo s
    deinitLock(l)
    echo "Done."
    
    
    Run

Reply via email to