I've have a code that makes some simulations and then extracts data about them. Each simulation is independent, so I've contemplated to use Threads, wich work just fine, except for the 'writing the data' part. I was looking for a way to write the data in a single file, writing one row as soon as one simulation ends (as opposed to writing it after every simulation is finished) so I came up with this.
However the data file it writes is a mess. I don't care about the order of the rows it writes, but sometimes it return empty rows or mixes them together.
Is there a way to write on to the same file while using Theads?