<?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[Probleme mit std::thread]]></title><description><![CDATA[<p>Hoi,<br />
ich glaub ich kann mir hier eine genaue Beschreibung sparen. Wieso funktioniert das nicht?</p>
<pre><code class="language-cpp">#include &lt;thread&gt;
#include &lt;iostream&gt;
#include &lt;unistd.h&gt;

void print_task()
{
   while(true)
   {
      std::cout &lt;&lt; &quot;Hello from &quot; &lt;&lt; getpid() &lt;&lt; '\n';
      usleep(5000000);
   }
}

int main()
{
   std::thread thread1(&amp;print_task);
   usleep(2500000);
   std::thread thread2(&amp;print_task);
   thread1.join();
   thread2.join();
}
</code></pre>
<p>Beim erzeugen des ersten Threads bekomme ich sofort ein</p>
<blockquote>
<p>terminate called after throwing an instance of 'std::system_error'<br />
what(): Operation not permitted<br />
Abgebrochen</p>
</blockquote>
<p>um die Ohren. An was könnte es liegen?</p>
<p>Danke und Grüße,<br />
Ethon</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/295224/probleme-mit-std-thread</link><generator>RSS for Node</generator><lastBuildDate>Sat, 15 Aug 2026 12:47:32 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/295224.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 09 Nov 2011 14:59:02 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Probleme mit std::thread on Wed, 09 Nov 2011 14:59:02 GMT]]></title><description><![CDATA[<p>Hoi,<br />
ich glaub ich kann mir hier eine genaue Beschreibung sparen. Wieso funktioniert das nicht?</p>
<pre><code class="language-cpp">#include &lt;thread&gt;
#include &lt;iostream&gt;
#include &lt;unistd.h&gt;

void print_task()
{
   while(true)
   {
      std::cout &lt;&lt; &quot;Hello from &quot; &lt;&lt; getpid() &lt;&lt; '\n';
      usleep(5000000);
   }
}

int main()
{
   std::thread thread1(&amp;print_task);
   usleep(2500000);
   std::thread thread2(&amp;print_task);
   thread1.join();
   thread2.join();
}
</code></pre>
<p>Beim erzeugen des ersten Threads bekomme ich sofort ein</p>
<blockquote>
<p>terminate called after throwing an instance of 'std::system_error'<br />
what(): Operation not permitted<br />
Abgebrochen</p>
</blockquote>
<p>um die Ohren. An was könnte es liegen?</p>
<p>Danke und Grüße,<br />
Ethon</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2142551</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2142551</guid><dc:creator><![CDATA[Ethon]]></dc:creator><pubDate>Wed, 09 Nov 2011 14:59:02 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme mit std::thread on Wed, 09 Nov 2011 15:05:42 GMT]]></title><description><![CDATA[<p>Für mal als root das Programm aus.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2142552</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2142552</guid><dc:creator><![CDATA[sudo ku]]></dc:creator><pubDate>Wed, 09 Nov 2011 15:05:42 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme mit std::thread on Wed, 09 Nov 2011 15:18:52 GMT]]></title><description><![CDATA[<p>Bereits probiert und auch nicht wirklich sinnvoll ... wieso sollten non-root Programme keine Threads erstellen dürfen. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2142557</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2142557</guid><dc:creator><![CDATA[Ethon]]></dc:creator><pubDate>Wed, 09 Nov 2011 15:18:52 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme mit std::thread on Wed, 09 Nov 2011 15:53:15 GMT]]></title><description><![CDATA[<p>Ich weiß zwar nicht was passiert, wenn du es nicht machst und wieso sich das Programm dann überhaupt erzeugen lässt, aber: Du musst noch gegen pthread linken, dann funktioniert's.</p>
<p>edit: Oder besser noch, falls du den gcc benutzt: Die -pthread-Option linkt nicht nur gegen libpthread, sondern macht auch, dass gewisse Standardfunktionen reentrant werden, was sicher nützlich ist, wenn man mit threads arbeitet.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2142566</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2142566</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Wed, 09 Nov 2011 15:53:15 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme mit std::thread on Wed, 09 Nov 2011 16:58:27 GMT]]></title><description><![CDATA[<p>stop mal!</p>
<p>std::thread? ich denk das ist erst beim neuen standard dabei, und bisher noch nicht supportet?!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2142588</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2142588</guid><dc:creator><![CDATA[Skym0sh0]]></dc:creator><pubDate>Wed, 09 Nov 2011 16:58:27 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme mit std::thread on Wed, 09 Nov 2011 18:41:00 GMT]]></title><description><![CDATA[<p>SeppJ schrieb:</p>
<blockquote>
<p>Ich weiß zwar nicht was passiert, wenn du es nicht machst und wieso sich das Programm dann überhaupt erzeugen lässt, aber: Du musst noch gegen pthread linken, dann funktioniert's.</p>
<p>edit: Oder besser noch, falls du den gcc benutzt: Die -pthread-Option linkt nicht nur gegen libpthread, sondern macht auch, dass gewisse Standardfunktionen reentrant werden, was sicher nützlich ist, wenn man mit threads arbeitet.</p>
</blockquote>
<p>Das hilft, danke. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /><br />
Ich frag mich nur wieso man das manuell machen muss, der Rest der Standard-Bibliothek muss ja auch nicht manuell gelinkt werden ...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2142635</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2142635</guid><dc:creator><![CDATA[Ethon]]></dc:creator><pubDate>Wed, 09 Nov 2011 18:41:00 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme mit std::thread on Thu, 10 Nov 2011 08:15:45 GMT]]></title><description><![CDATA[<p>Skym0sh0 schrieb:</p>
<blockquote>
<p>std::thread? ich denk das ist erst beim neuen standard dabei, und bisher noch nicht supportet?!</p>
</blockquote>
<p>Kommt auf den Compiler bzw. die Bibliothek an. MSVC2010 und GCC (ich glaube ab 4.6) haben std::thread schon mit drin.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2142741</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2142741</guid><dc:creator><![CDATA[pumuckl]]></dc:creator><pubDate>Thu, 10 Nov 2011 08:15:45 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme mit std::thread on Thu, 10 Nov 2011 09:33:18 GMT]]></title><description><![CDATA[<p>pumuckl schrieb:</p>
<blockquote>
<p>Skym0sh0 schrieb:</p>
<blockquote>
<p>std::thread? ich denk das ist erst beim neuen standard dabei, und bisher noch nicht supportet?!</p>
</blockquote>
<p>Kommt auf den Compiler bzw. die Bibliothek an. MSVC2010 und GCC (ich glaube ab 4.6) haben std::thread schon mit drin.</p>
</blockquote>
<p>Also mein MSVC2010 hat &lt;thread&gt; noch nicht. Aber in VC++11 soll es kommen.</p>
<p><a href="http://blogs.msdn.com/b/vcblog/archive/2011/09/12/10209291.aspx" rel="nofollow">http://blogs.msdn.com/b/vcblog/archive/2011/09/12/10209291.aspx</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2142772</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2142772</guid><dc:creator><![CDATA[_matze]]></dc:creator><pubDate>Thu, 10 Nov 2011 09:33:18 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme mit std::thread on Thu, 10 Nov 2011 09:51:24 GMT]]></title><description><![CDATA[<p>pumuckl schrieb:</p>
<blockquote>
<p>GCC (ich glaube ab 4.6) haben std::thread schon mit drin.</p>
</blockquote>
<p>std::thread gibt es seit gcc-4.4.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2142782</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2142782</guid><dc:creator><![CDATA[huigretl]]></dc:creator><pubDate>Thu, 10 Nov 2011 09:51:24 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme mit std::thread on Thu, 10 Nov 2011 10:18:53 GMT]]></title><description><![CDATA[<p>Sry, da hab ich wohl falsch gelegen - GCC kenn ich nicht gut genug und MSVC war ich der Meinung, in meinem Code bereits std::thread zu benutzen - denkste...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2142795</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2142795</guid><dc:creator><![CDATA[pumuckl]]></dc:creator><pubDate>Thu, 10 Nov 2011 10:18:53 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme mit std::thread on Thu, 10 Nov 2011 12:36:01 GMT]]></title><description><![CDATA[<p>Dachte auch der MSVC 2011 kann keine variadic Templates? Dann wird auch der std::thread nur teilweise unterstützen können.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2142867</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2142867</guid><dc:creator><![CDATA[Ethon_]]></dc:creator><pubDate>Thu, 10 Nov 2011 12:36:01 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme mit std::thread on Thu, 10 Nov 2011 12:56:14 GMT]]></title><description><![CDATA[<p>Ethon_ schrieb:</p>
<blockquote>
<p>Dachte auch der MSVC 2011 kann keine variadic Templates? Dann wird auch der std::thread nur teilweise unterstützen können.</p>
</blockquote>
<p>MSVC2010 bietet für viele variadics aus der Standardbibliothek entsprechende Überladungen für 0-&lt;MagicNumber&gt; Argumente, so wie es Boost auch macht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2142879</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2142879</guid><dc:creator><![CDATA[pumuckl]]></dc:creator><pubDate>Thu, 10 Nov 2011 12:56:14 GMT</pubDate></item></channel></rss>