<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[[SOLVED] Thread Finalizing]]></title><description><![CDATA[<p dir="auto">Hello my dear friends<br />
I have a simple scenario</p>
<p dir="auto">I want to start a thread using QThread class and finalize it when ever I want<br />
@<br />
class PlayerManager : public QThread@</p>
<p dir="auto">....</p>
<p dir="auto">@PlayerManager::PlayerManager(QObject *parent) :<br />
QThread(parent)<br />
{<br />
_isFinalized = false;<br />
connect(this, &amp;QThread::finished, this, &amp;QThread::deleteLater);<br />
start();<br />
}@</p>
<p dir="auto">in run method do some tasks</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/void">@<bdi>void</bdi></a> PlayerManager::run()<br />
{</p>
<pre><code>while (!(IsFinalized())) {
    _mutex.lock();
    //Do something
    _mutex.unlock();
    usleep(50);
}
</code></pre>
<p dir="auto">@<br />
and after that finalize it</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/void">@<bdi>void</bdi></a> PlayerManager::Finalize()<br />
{<br />
_mutex.lock();<br />
_isFinalized = true;<br />
_mutex.unlock();<br />
}</p>
<p dir="auto">bool PlayerManager::IsFinalized()<br />
{<br />
bool result;<br />
_mutex.lock();<br />
result = _isFinalized;<br />
_mutex.unlock();<br />
return result;<br />
}<br />
@<br />
I get instance of this class here</p>
<p dir="auto">@int main(int argc, char *argv[])<br />
{<br />
QCoreApplication a(argc, argv);<br />
PlayerManager pm;<br />
usleep(1000000);<br />
pm.Finalize();<br />
return a.exec();<br />
}<br />
@</p>
<p dir="auto">--but i recive this signal<br />
SIGABRT<br />
thank you</p>
]]></description><link>https://forum.qt.io/topic/35019/solved-thread-finalizing</link><generator>RSS for Node</generator><lastBuildDate>Wed, 24 Jun 2026 04:42:39 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/35019.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 03 Dec 2013 10:15:39 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [SOLVED] Thread Finalizing on Thu, 05 Dec 2013 13:15:34 GMT]]></title><description><![CDATA[<p dir="auto">Please,,Write [SOLVED] before Title if You found the answer,otherwise share your problem.</p>
]]></description><link>https://forum.qt.io/post/206391</link><guid isPermaLink="true">https://forum.qt.io/post/206391</guid><dc:creator><![CDATA[IamSumit]]></dc:creator><pubDate>Thu, 05 Dec 2013 13:15:34 GMT</pubDate></item><item><title><![CDATA[Reply to [SOLVED] Thread Finalizing on Tue, 03 Dec 2013 11:07:47 GMT]]></title><description><![CDATA[<p dir="auto">oops I found the answer</p>
<p dir="auto">@<br />
PlayerManager pm;<br />
@</p>
<p dir="auto">the correct</p>
<p dir="auto">@<br />
PlayerManager* pm = new PlayerManager();<br />
@</p>
]]></description><link>https://forum.qt.io/post/206077</link><guid isPermaLink="true">https://forum.qt.io/post/206077</guid><dc:creator><![CDATA[arashjfz]]></dc:creator><pubDate>Tue, 03 Dec 2013 11:07:47 GMT</pubDate></item></channel></rss>