# Using ROOT GUI in a multithread application

**URL:** <https://root-forum.cern.ch/t/using-root-gui-in-a-multithread-application/50915>\
**Category:** Newbie\
**Tags:** graphics, root\
**Created:** [July 22, 2022, 11:59am UTC](https://root-forum.cern.ch/t/using-root-gui-in-a-multithread-application/50915 "2022-07-22T11:59:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![DanielCussol](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/d/e9bcb4/32.png) [@DanielCussol](https://root-forum.cern.ch/u/DanielCussol)\
**Post date:** [July 22, 2022, 11:59am UTC](https://root-forum.cern.ch/t/using-root-gui-in-a-multithread-application/50915/1 "2022-07-22T11:59:49Z")

</div>

Hello ROOTers!  
I try to build a multi-thread application using GUI ROOT classes. It seems that some collisions appears between threads leading to a crash of my application. Is there any mandatory things to indicate in my source code of my application to avoid collisions and crashes ?

Thank you for your help

Daniel

* * *

_ROOT Version:_ 6.24/06  
_Platform:_ Ubuntu 20.04.1  
_Compiler:_ gcc 9.4.0

* * *

---

<div class="post-metadata">

**Author:** ![jalopezg](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/jalopezg/32/25844_2.png) [@jalopezg](https://root-forum.cern.ch/u/jalopezg)\
**Post date:** [July 22, 2022, 12:03pm UTC](https://root-forum.cern.ch/t/using-root-gui-in-a-multithread-application/50915/2 "2022-07-22T12:03:26Z")

</div>

Hi @DanielCussol,

Take a look at [ROOT::EnableThreadSafety()](https://root.cern/doc/v608/namespaceROOT.html#a3332c2f629881ab608768fa6846f440e).

Perhaps, and depending on your use case, you might also be interested in [ROOT::EnableImplicitMT()](https://root.cern/doc/v608/namespaceROOT.html#ade6e397b327482d267ad54de92db4b89).

Cheers,  
J.

---

<div class="post-metadata">

**Author:** ![linev](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/l/2bfe46/32.png) [@linev](https://root-forum.cern.ch/u/linev)\
**Post date:** [July 22, 2022, 12:25pm UTC](https://root-forum.cern.ch/t/using-root-gui-in-a-multithread-application/50915/3 "2022-07-22T12:25:52Z")

</div>

Hi Daniel,

Be aware that ROOT graphics is not thread safe and should be handled always from the main thread.

Regards,  
Sergey

---

<div class="post-metadata">

**Author:** ![DanielCussol](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/d/e9bcb4/32.png) [@DanielCussol](https://root-forum.cern.ch/u/DanielCussol)\
**Post date:** [August 2, 2022, 8:48am UTC](https://root-forum.cern.ch/t/using-root-gui-in-a-multithread-application/50915/4 "2022-08-02T08:48:41Z")

</div>

Hi Seguey,  
Thank you for your answer. It seems that the use of a TTimer or a derived class of TTimer to update widget contents leads to the crash. It seems that updating the widget content in a specific thread works.

Regards

Daniel

---

<div class="post-metadata">

**Author:** ![DanielCussol](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/d/e9bcb4/32.png) [@DanielCussol](https://root-forum.cern.ch/u/DanielCussol)\
**Post date:** [August 2, 2022, 8:50am UTC](https://root-forum.cern.ch/t/using-root-gui-in-a-multithread-application/50915/5 "2022-08-02T08:50:54Z")

</div>

Thank you for your answer. I have call the ROOT::EnableThreadSafety() method but the problem was still there. It seems that the use of a TTimer or a derived class of TTimer to update widget contents leads to the crash. It seems that updating the widget content in a specific thread works.

Thank you for your help !  
Daniel
