# Thread safe fill of same tree and histograms from different synchronized threads

**URL:** <https://root-forum.cern.ch/t/thread-safe-fill-of-same-tree-and-histograms-from-different-synchronized-threads/55258>\
**Category:** ROOT\
**Tags:** tree, hist\
**Created:** [June 11, 2023, 7:58am UTC](https://root-forum.cern.ch/t/thread-safe-fill-of-same-tree-and-histograms-from-different-synchronized-threads/55258 "2023-06-11T07:58:26Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![pcanal](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pcanal/32/12439_2.png) [@pcanal](https://root-forum.cern.ch/u/pcanal)\
**Post date:** [June 13, 2023, 5:20pm UTC](https://root-forum.cern.ch/t/thread-safe-fill-of-same-tree-and-histograms-from-different-synchronized-threads/55258/3 "2023-06-13T17:20:59Z")

</div>

Individual objects of type `TTree` or `TH1*` (or `TFile`) can not n be accessed from multiple thread as the same time. However once you turn on thread support in ROOT (`ROOT::EnableThreadSafety()`) distinct objects of those types can be access concurrently.

I.e. what you described will work but you might also be able to achieve even better thread scaling by using (in some cases) distinct objects rather than sharing them with several thread (We also have an infrastructure (`TBufferMerger`) that allows the merging of concurrently produced `TTree` and `TH*`

---

_[View the full topic](https://root-forum.cern.ch/t/thread-safe-fill-of-same-tree-and-histograms-from-different-synchronized-threads/55258)._
