<?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[array of threads erzeugen]]></title><description><![CDATA[<p>Ich will für einen unsigned int anzahl_threads</p>
<p>anzahl_threads Threads erstellen, wobei jedem Thread eine von seiner Nummer abhängige unsigned int übergeben werden soll. Wie mache ich das?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/322445/array-of-threads-erzeugen</link><generator>RSS for Node</generator><lastBuildDate>Fri, 17 Jul 2026 21:37:40 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/322445.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 20 Dec 2013 18:00:52 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to array of threads erzeugen on Fri, 20 Dec 2013 18:00:52 GMT]]></title><description><![CDATA[<p>Ich will für einen unsigned int anzahl_threads</p>
<p>anzahl_threads Threads erstellen, wobei jedem Thread eine von seiner Nummer abhängige unsigned int übergeben werden soll. Wie mache ich das?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2373077</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2373077</guid><dc:creator><![CDATA[threadsssssss]]></dc:creator><pubDate>Fri, 20 Dec 2013 18:00:52 GMT</pubDate></item><item><title><![CDATA[Reply to array of threads erzeugen on Fri, 20 Dec 2013 19:06:25 GMT]]></title><description><![CDATA[<pre><code>#include &lt;iostream&gt;
#include &lt;future&gt;

void machwas(unsigned int ui){

}

int main(){
	unsigned int anzahl_threads;
	if (std::cin &gt;&gt; anzahl_threads){
		for (unsigned int thread_nr = 0; thread_nr &lt; anzahl_threads; thread_nr++)
			std::async(std::launch::async, machwas, thread_nr);
	}
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2373091</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2373091</guid><dc:creator><![CDATA[nwp3]]></dc:creator><pubDate>Fri, 20 Dec 2013 19:06:25 GMT</pubDate></item><item><title><![CDATA[Reply to array of threads erzeugen on Fri, 20 Dec 2013 22:47:34 GMT]]></title><description><![CDATA[<p>nwp3 schrieb:</p>
<blockquote>
<p>std::async(std::launch::async, machwas, thread_nr);</p>
</blockquote>
<p>Nö, so geht das nicht. std::async kannst du in die Tonne rühren, das ist völlig nutzlos (siehe <a href="http://en.cppreference.com/w/cpp/thread/async#Notes" rel="nofollow">cppreference</a>).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2373100</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2373100</guid><dc:creator><![CDATA[async async = not async]]></dc:creator><pubDate>Fri, 20 Dec 2013 22:47:34 GMT</pubDate></item><item><title><![CDATA[Reply to array of threads erzeugen on Fri, 20 Dec 2013 23:25:00 GMT]]></title><description><![CDATA[<p>Was wäre dann ein geeigneter Ansatz um das Problem zu lösen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2373102</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2373102</guid><dc:creator><![CDATA[Hellhound66]]></dc:creator><pubDate>Fri, 20 Dec 2013 23:25:00 GMT</pubDate></item><item><title><![CDATA[Reply to array of threads erzeugen on Sat, 21 Dec 2013 00:39:50 GMT]]></title><description><![CDATA[<p>anzahl_threads einlesen, entsprechend viele std::thread erstellen und sie mit entsprechendem wert starten ?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2373113</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2373113</guid><dc:creator><![CDATA[DarkShadow44]]></dc:creator><pubDate>Sat, 21 Dec 2013 00:39:50 GMT</pubDate></item><item><title><![CDATA[Reply to array of threads erzeugen on Sat, 21 Dec 2013 10:19:56 GMT]]></title><description><![CDATA[<p>async async = not async schrieb:</p>
<blockquote>
<p>nwp3 schrieb:</p>
<blockquote>
<p>std::async(std::launch::async, machwas, thread_nr);</p>
</blockquote>
<p>Nö, so geht das nicht. std::async kannst du in die Tonne rühren, das ist völlig nutzlos (siehe <a href="http://en.cppreference.com/w/cpp/thread/async#Notes" rel="nofollow">cppreference</a>).</p>
</blockquote>
<pre><code>#include &lt;iostream&gt;
#include &lt;future&gt;
#include &lt;vector&gt;

void machwas(unsigned int ui){

}

int main(){
	unsigned int anzahl_threads;
	if (std::cin &gt;&gt; anzahl_threads){
		std::vector&lt;decltype (std::async(std::launch::async, machwas, 0u))&gt; thread_array;
		thread_array.reserve(anzahl_threads);
		for (unsigned int thread_nr = 0; thread_nr &lt; anzahl_threads; thread_nr++)
			thread_array.push_back(std::async(std::launch::async, machwas, thread_nr));
		for (auto &amp;t : thread_array)
			t.wait(); //t.get() wenn machwas einen sinnvollen returnwert hat
	}
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2373128</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2373128</guid><dc:creator><![CDATA[nwp3]]></dc:creator><pubDate>Sat, 21 Dec 2013 10:19:56 GMT</pubDate></item><item><title><![CDATA[Reply to array of threads erzeugen on Sat, 21 Dec 2013 12:55:30 GMT]]></title><description><![CDATA[<p>Ich persönlich finde Threading mit C++11 noch etwas undurchsichtig, weshalb ich über verschiedene Lösungsstrategien dankbar bin.</p>
<p>Danke nochmal für die Antwort.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2373140</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2373140</guid><dc:creator><![CDATA[Hellhound66]]></dc:creator><pubDate>Sat, 21 Dec 2013 12:55:30 GMT</pubDate></item><item><title><![CDATA[Reply to array of threads erzeugen on Sat, 21 Dec 2013 13:06:47 GMT]]></title><description><![CDATA[<p>nwp3 schrieb:</p>
<blockquote>
<pre><code>for (unsigned int thread_nr = 0; thread_nr &lt; anzahl_threads; thread_nr++)
	thread_array.push_back(std::async(std::launch::async, machwas, thread_nr));
</code></pre>
</blockquote>
<p>immer noch falsch. std::async(std::launch::async,...) kann blockieren.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2373143</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2373143</guid><dc:creator><![CDATA[async async = not async]]></dc:creator><pubDate>Sat, 21 Dec 2013 13:06:47 GMT</pubDate></item><item><title><![CDATA[Reply to array of threads erzeugen on Sat, 21 Dec 2013 13:49:44 GMT]]></title><description><![CDATA[<p>Joa die meisten Threading-Implementierungen in C++ 11 sind doch broken.<br />
Lieber ne ausgereifte Bibliothek dafür benutzen z.B. QT.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2373147</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2373147</guid><dc:creator><![CDATA[wx]]></dc:creator><pubDate>Sat, 21 Dec 2013 13:49:44 GMT</pubDate></item><item><title><![CDATA[Reply to array of threads erzeugen on Sat, 21 Dec 2013 14:17:09 GMT]]></title><description><![CDATA[<p>async async = not async schrieb:</p>
<blockquote>
<p>immer noch falsch. std::async(std::launch::async,...) kann blockieren.</p>
</blockquote>
<p>Wo kann man das nachlesen? So wie ich die Doku lese darf es das nicht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2373152</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2373152</guid><dc:creator><![CDATA[nwp3]]></dc:creator><pubDate>Sat, 21 Dec 2013 14:17:09 GMT</pubDate></item><item><title><![CDATA[Reply to array of threads erzeugen on Sat, 21 Dec 2013 14:37:29 GMT]]></title><description><![CDATA[<p>async async = not async schrieb:</p>
<blockquote>
<p>nwp3 schrieb:</p>
<blockquote>
<pre><code>for (unsigned int thread_nr = 0; thread_nr &lt; anzahl_threads; thread_nr++)
	thread_array.push_back(std::async(std::launch::async, machwas, thread_nr));
</code></pre>
</blockquote>
<p>immer noch falsch. std::async(std::launch::async,...) kann blockieren.</p>
</blockquote>
<p>Wo steht das?<br />
<code>~future()</code> kann blockieren. Das sollte hier doch aber nicht stören, wenn's ordentlich auf den Heap gemoved wird. Oder?<br />
Ich hätte wohl <code>emplace_back()</code> genommen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2373161</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2373161</guid><dc:creator><![CDATA[Caligulaminus]]></dc:creator><pubDate>Sat, 21 Dec 2013 14:37:29 GMT</pubDate></item></channel></rss>