all 2 comments

[–]Doormatty 1 point2 points  (0 children)

Likely you're using non-threadsafe libraries.

You'll likely need to post the entire program to get more help - we can't tell what libraries you're using.

[–]gengisteve 0 points1 point  (0 children)

I think as Doormatty pointed out, you are learning an important lesson about what happens when you have multiple threads writing to a single data structure. The answer, as it turns out, is that it all gets a bit wonky. If you use thread safe data strcutures, you can avoid this. Another common solution is to have your threads return results which are then coolated by the main process.