The test case that works in single threaded mode, but not in multithreaded mode.
Compile with --gc:arc --threads:on
import threadpool
import strutils
import os
proc work(s: string) =
let (abs_dir, file_ext) = splitPath(s)
echo file_ext # needed to make task heavier to produce race conditions
doAssert(file_ext.endsWith(".xml"))
proc thread_run(p: string, singleThread = false) =
let path = p
if singleThread:
work(path)
else:
spawn(work(path))
var i = 0
for path in walkDirRec(r"c:\"):
if splitFile(path).ext == ".xml":
echo path
thread_run(path, singleThread = false) # works if singleThread = true
i.inc
if i >= 1000:
break
sync()