<?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[Exceptions und Multithreading]]></title><description><![CDATA[<p>Hallo,<br />
Ich versuche gerade meine ersten Programme mit mehreren Threads zu schreiben.</p>
<pre><code class="language-cpp">class A {};

void thread()
{
    //irgendetwas
    throw A;
}

int main()
{
    try
    {
        //startet thread als thread ;)
        //...
    }
    catch(const A&amp; a)
    {
        std::cout &lt;&lt; &quot;A abgefangen!&quot; &lt;&lt; endl;
    }
    return 0;
}
</code></pre>
<p>Das Programm müsste eigentlich ja abstürzen (weil A nicht abgefangen wird -&gt; terminate()).<br />
Aber wie fange ich in einem solchen Fall A ab oder gibt es bessere Vorschläge?</p>
<p>mfg D3lta</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/295178/exceptions-und-multithreading</link><generator>RSS for Node</generator><lastBuildDate>Sat, 15 Aug 2026 12:47:35 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/295178.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 08 Nov 2011 17:32:04 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Exceptions und Multithreading on Tue, 08 Nov 2011 17:32:04 GMT]]></title><description><![CDATA[<p>Hallo,<br />
Ich versuche gerade meine ersten Programme mit mehreren Threads zu schreiben.</p>
<pre><code class="language-cpp">class A {};

void thread()
{
    //irgendetwas
    throw A;
}

int main()
{
    try
    {
        //startet thread als thread ;)
        //...
    }
    catch(const A&amp; a)
    {
        std::cout &lt;&lt; &quot;A abgefangen!&quot; &lt;&lt; endl;
    }
    return 0;
}
</code></pre>
<p>Das Programm müsste eigentlich ja abstürzen (weil A nicht abgefangen wird -&gt; terminate()).<br />
Aber wie fange ich in einem solchen Fall A ab oder gibt es bessere Vorschläge?</p>
<p>mfg D3lta</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2142255</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2142255</guid><dc:creator><![CDATA[D3lta]]></dc:creator><pubDate>Tue, 08 Nov 2011 17:32:04 GMT</pubDate></item><item><title><![CDATA[Reply to Exceptions und Multithreading on Tue, 08 Nov 2011 17:56:20 GMT]]></title><description><![CDATA[<p>Exceptions werden typischerweise nur im aktuellen Thread nach oben gereicht.<br />
Ein mögliche Lösung ist std::exception_ptr von C++011 oder boost::exception_ptr.</p>
<p>std::exception_ptr: <a href="http://msdn.microsoft.com/en-us/library/dd293602.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/dd293602.aspx</a><br />
boost::exception_ptr: <a href="http://www.boost.org/doc/libs/1_47_0/libs/exception/doc/boost-exception.html" rel="nofollow">http://www.boost.org/doc/libs/1_47_0/libs/exception/doc/boost-exception.html</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2142266</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2142266</guid><dc:creator><![CDATA[theta]]></dc:creator><pubDate>Tue, 08 Nov 2011 17:56:20 GMT</pubDate></item><item><title><![CDATA[Reply to Exceptions und Multithreading on Tue, 08 Nov 2011 20:00:41 GMT]]></title><description><![CDATA[<p>theta schrieb:</p>
<blockquote>
<p>Exceptions werden typischerweise nur im aktuellen Thread nach oben gereicht.<br />
Ein mögliche Lösung ist std::exception_ptr von C++011 oder boost::exception_ptr.</p>
<p>std::exception_ptr: <a href="http://msdn.microsoft.com/en-us/library/dd293602.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/dd293602.aspx</a><br />
boost::exception_ptr: <a href="http://www.boost.org/doc/libs/1_47_0/libs/exception/doc/boost-exception.html" rel="nofollow">http://www.boost.org/doc/libs/1_47_0/libs/exception/doc/boost-exception.html</a></p>
</blockquote>
<p>Danke, jetzt sollte das Exceptionhandling im ganzen Programm funktionieren <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f44d.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--thumbs_up"
      title=":+1:"
      alt="👍"
    /><br />
std::exception_ptr ist doch die in den Standart übernommene Version von boost::exception_ptr, oder?</p>
<p>mfg D3lta</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2142328</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2142328</guid><dc:creator><![CDATA[D3lta]]></dc:creator><pubDate>Tue, 08 Nov 2011 20:00:41 GMT</pubDate></item></channel></rss>