I am trying to test memory fragmentation after thread destruction, but I don't
know how to destroy threads properly. What is wrong with this program?
import os
var threads: seq[Thread[int]]
proc wait(s: int) =
for i in 0..10:
var x = newStringOfCap(100000*(11-i))
os.sleep(s*1000)
proc cycle() =
for i in 0..threads.high:
assert(not running(threads[i]))
createThread(threads[i], wait, 1)
echo "Joining", threads.len
joinThreads(threads)
echo "Joined", threads.len
proc main() =
newSeq(threads, 4)
for i in 0..30:
cycle()
main()
Joining4
Joined4
Joining4
.... (hangs here)
- How to create, destroy, and recreate threads cdunn2001
- Re: How to create, destroy, and recreate threads cdunn2001
- Re: How to create, destroy, and recreate threads Stefan_Salewski
- Re: How to create, destroy, and recreate thre... Jehan
- Re: How to create, destroy, and recreate ... cheatfate
- Re: How to create, destroy, and recr... cheatfate
- Re: How to create, destroy, and ... cdunn2001
- Re: How to create, destroy, ... cheatfate
- Re: How to create, destroy, ... cdunn2001
- Re: How to create, destroy, ... cdunn2001
- Re: How to create, destroy, ... Araq
