I don't think threads run slower in my case. I changed your program slightly to support threads and non threads: [https://play.nim-lang.org/#ix=2bFk](https://play.nim-lang.org/#ix=2bFk) nim c -d:release -d:danger --threads:on "/p/tmp/prisoners.nim" time ./prisoners Succs: 311894 Fails: 688106 Total: 1000000 Success Rate: 31.1894%. Succs: 0 Fails: 1000000 Total: 1000000 Success Rate: 0.0%. real 0m8.288s user 0m15.779s sys 0m0.008s Run nim c -d:release -d:danger "/p/tmp/prisoners.nim" time ./prisoners Succs: 312323 Fails: 687677 Total: 1000000 Success Rate: 31.2323%. Succs: 0 Fails: 1000000 Total: 1000000 Success Rate: 0.0%. real 0m11.459s user 0m11.452s Run
Threads took 8s while non threads took 11s. Threads are faster. I only have two cores on this linux box so speed it was not that huge. Some thoughts: This code does call toSeq inside for loops for optimal speed there might be a way to allocate it only once and reuse it per thread. You are using random numbers ... randomness might be causing different runs take different times. You are using a global random which might not work great when accessed from different threads.