<?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[Problem mit Thread und Klasse]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich habe folgendes Problem: Ich habe eine Klasse. Mit einer Methode greife ich auf diese zu. Diese Methode soll dann einen Thread starten.<br />
Der Code sieht folgendermaßen aus:</p>
<pre><code>#include &lt;thread&gt;

void tthread()
{
    //bla
};

class Klasse
{
    void erzeugen()
    {
        std::thread th(tthread);
    };
};

int main()
{
    Klasse *Kla = new Klasse;
    Kla-&gt;erzeugen();
};
</code></pre>
<p>Der Code wird bei der Ausführung mit einem Abbruch beendet.<br />
Ich hoffe, ihr könnt mir helfen.</p>
<p>Gruß</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/312095/problem-mit-thread-und-klasse</link><generator>RSS for Node</generator><lastBuildDate>Mon, 03 Aug 2026 16:18:44 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/312095.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 23 Dec 2012 20:25:22 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Problem mit Thread und Klasse on Sun, 23 Dec 2012 20:25:22 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich habe folgendes Problem: Ich habe eine Klasse. Mit einer Methode greife ich auf diese zu. Diese Methode soll dann einen Thread starten.<br />
Der Code sieht folgendermaßen aus:</p>
<pre><code>#include &lt;thread&gt;

void tthread()
{
    //bla
};

class Klasse
{
    void erzeugen()
    {
        std::thread th(tthread);
    };
};

int main()
{
    Klasse *Kla = new Klasse;
    Kla-&gt;erzeugen();
};
</code></pre>
<p>Der Code wird bei der Ausführung mit einem Abbruch beendet.<br />
Ich hoffe, ihr könnt mir helfen.</p>
<p>Gruß</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2282813</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2282813</guid><dc:creator><![CDATA[NE_81]]></dc:creator><pubDate>Sun, 23 Dec 2012 20:25:22 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit Thread und Klasse on Sun, 23 Dec 2012 20:42:27 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">#include &lt;thread&gt;
#include &lt;iostream&gt;

void my_thread()
{
	std::cout &lt;&lt; &quot;Hello, thread!&quot; &lt;&lt; std::endl;
}

class my_class_t
{
	private:
		std::thread thread;

		my_class_t( my_class_t const &amp; ); // not copyable

	public:
		my_class_t() : thread() {}
		~my_class_t() { thread.join(); }

		void run() { thread = std::thread( my_thread ); }
};

int main()
{
	my_class_t my_class;

	my_class.run();
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2282820</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2282820</guid><dc:creator><![CDATA[Swordfish]]></dc:creator><pubDate>Sun, 23 Dec 2012 20:42:27 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit Thread und Klasse on Sun, 23 Dec 2012 20:42:00 GMT]]></title><description><![CDATA[<p>Fang doch mal die exception ab.<br />
Vielleicht hast du aber auch einen Fehler in der Funktion.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2282822</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2282822</guid><dc:creator><![CDATA[Marthog]]></dc:creator><pubDate>Sun, 23 Dec 2012 20:42:00 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit Thread und Klasse on Sun, 23 Dec 2012 20:44:50 GMT]]></title><description><![CDATA[<p>Marthog schrieb:</p>
<blockquote>
<p>Fang doch mal die exception ab.</p>
</blockquote>
<p>Welche denn?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2282823</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2282823</guid><dc:creator><![CDATA[Swordfish]]></dc:creator><pubDate>Sun, 23 Dec 2012 20:44:50 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit Thread und Klasse on Mon, 24 Dec 2012 08:36:05 GMT]]></title><description><![CDATA[<p>Danke, es funktioniert.</p>
<p>Gruß</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2282921</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2282921</guid><dc:creator><![CDATA[NE_81]]></dc:creator><pubDate>Mon, 24 Dec 2012 08:36:05 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit Thread und Klasse on Mon, 24 Dec 2012 10:29:07 GMT]]></title><description><![CDATA[<p>Jetzt habe ich ein weiteres Problem: Wenn ich die Methode für den Thread nocheinmal aufrufe, dann bricht das Programm erneut ab.</p>
<p>Die main()-Funktion umgeschrieben, so wie ich es meine:</p>
<pre><code>int main()
{
    my_class_t my_class;
    while(true)
    {
        //5 Sekunden warten
        my_class.run();
    }
}
</code></pre>
<p>Gibt es dafür auch eine Lösung?</p>
<p>Gruß</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2282940</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2282940</guid><dc:creator><![CDATA[NE_81]]></dc:creator><pubDate>Mon, 24 Dec 2012 10:29:07 GMT</pubDate></item></channel></rss>