On Mon, Mar 17, 2008 at 9:17 AM, Hal Vaughan &lt;<a href="mailto:hal@thresholddigital.com">hal@thresholddigital.com</a>&gt; wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
So when I did just a loop in a routine that printed numbers 1-10 (or, when I<br>
experimented, 1-1000), and thread 1 always finished completely before<br>
thread 2 could start, is that the same? &nbsp;Is there any way I can get the two<br>
threads to run concurrently?</blockquote><div><br>Either give the threads more work to do (print *all* integers), or sleep for a second between each int.&nbsp; <br>&nbsp;</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
... I was hoping there might be a way, in C++, to spin off<br>
this listener thread, let it keep listening and processing the data, and<br>
have it stay in the background so other threads can continue.</blockquote><div><br>You can do this in C++ w/ practically any threading library.<br>&nbsp;<br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
So is there no way to create a thread and not have it take up all the CPU<br>
time until it&#39;s done without using SMP?</blockquote><div><br>Throw in a periodic nanosleep (or whatever) call if the worker thread is doing too much work.&nbsp; This will yield the processor to another thread or process.<br>
</div></div><br>Jon<br>