<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Help to understand spawning of threads</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/89761/help-to-understand-spawning-of-threads</link><description>Hi, I try to understand how to use the k_thread_create() to spawn a function (here called spam()) that takes a argument, and then runs with the argument. This code will not build, but what do I have to do to be able to build it? Thanks for any help 
</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 07 Jul 2022 16:33:17 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/89761/help-to-understand-spawning-of-threads" /><item><title>RE: Help to understand spawning of threads</title><link>https://devzone.nordicsemi.com/thread/376067?ContentTypeID=1</link><pubDate>Thu, 07 Jul 2022 16:33:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0dcc5edb-e832-4552-8f68-b24ee3bd8c55</guid><dc:creator>Raoul</dc:creator><description>&lt;p&gt;Hi Elias,&lt;/p&gt;
&lt;p&gt;Your compiler is probably complaining about your use of (void)spam(&amp;amp;c) in k_thread_create() on line 29. Arguments p1, p2 and p3 of k_thread_create() are there for you to provide arguments for your thread entry function. So in this case, all you have to do is move the argument of spam() into the neighbouring argument like so:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;k_tid_t my_tid = k_thread_create(&amp;amp;my_thread_data, my_stack_area, 
                                    K_THREAD_STACK_SIZEOF(my_stack_area), 
                                    spam, &amp;amp;c, NULL, NULL, 
                                    THREAD_PRIORITY, 0, K_NO_WAIT);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;When I do that on my machine, I can see your two threads writing &amp;quot;HI&amp;quot; alternatingly. Hope this helps.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Raoul Pathak&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>