I have a parallel process in R that should save results from each thread to one common file. But doing so creates problem as there is data overlap. I do aggregate in a data-frame and can write all the data at once in the end but since the data is huge, I want to make sure that data is not lost if system runs out of memory or something else happens. How do i write to one file and make sure that file is locked or data is written asynchronously. I am running my code on Windows just in case and am using I have a parallel process in R that should save