Hmm, I guess this will be "fun" to debug. Couple more questions:
- you mentioned that it happens after using cout, what happens if you don't use it?
- How many threads are you starting and from where? All from main thread? Or each thread starts another thread?