QDebug() Thread Safe ?
-
While debugging a deadlock problem I came to wonder if qDebug is thread safe, can it really be true it isn't ?
The documentation does not explicit mention if it is thread safe or not.
-
Rule of thumb: If the documentation does not state that something is thread safe, it is not. But I wonder how qDebug() can be involved in a deadlock problem, since it should be reentrant.
-
I know this is old but as of 2021/Qt 5 the documentation indicates it is thread safe:
https://doc.qt.io/qt-5/qtglobal.html#qDebug -
@James-Mark-Chan said in QDebug() Thread Safe ?:
I know this is old but as of 2021/Qt 5 the documentation indicates it is thread safe:
https://doc.qt.io/qt-5/qtglobal.html#qDebugqDebug()
is thread-safe. That means your program won't get corrupted or crash if you use qDebug() in multiple threads.However, qDebug() sends data to
stderr
which is unbuffered. That means ifstderr
receives data from multiple threads, it might display the data in a way that looks jumbled.