
On Mon, Mar 17, 2008 at 9:17 AM, Hal Vaughan
So when I did just a loop in a routine that printed numbers 1-10 (or, when I experimented, 1-1000), and thread 1 always finished completely before thread 2 could start, is that the same? Is there any way I can get the two threads to run concurrently?
Either give the threads more work to do (print *all* integers), or sleep for a second between each int.
... I was hoping there might be a way, in C++, to spin off this listener thread, let it keep listening and processing the data, and have it stay in the background so other threads can continue.
You can do this in C++ w/ practically any threading library.
So is there no way to create a thread and not have it take up all the CPU time until it's done without using SMP?
Throw in a periodic nanosleep (or whatever) call if the worker thread is doing too much work. This will yield the processor to another thread or process. Jon