ROOT I/O and thread safety

I’d like to understand whether ROOT I/O is thread safe. In particular, I’d like to understand whether two different threads can safely create histograms, manipulate them and write them in two different files (one file per thread), with ROOT 5.18.00.

Any direct reply, or a pointer to any documentation/FAQ/presentation would be appreciated.



You should be able to manipulate 2 different files in 2 separate thread as of v5.20. However note that the variable gDirectory and gFile are still shared between the 2 thread and hence you should not rely on any interface that use gDirectory/gFile (like TObject::Write or the auto-addending behavior of histograms). I.e. do TFile * f = TFile::Open(filename,"RECREATE"); TH1F *h = new TH1F(....); h->SetDirectory(f);