Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Post History
Because you are using Qt in particular there is something to be said for not solving this problem yourself. Instead, create a single object that owns the stream or file and offers a writeLine slot...
Answer
#1: Initial revision
Because you are using Qt in particular there is something to be said for *not solving this problem yourself*. Instead, create a single object that owns the stream or file and offers a `writeLine` slot. In the simplest case the signature might be `writeLine(const QString & line)`. Then your threads simple signal the owner with the data they want to write and the Qt engine takes care of the locking for you.