> using multiple threads in your application it not assure you that both
> your cores will be used, most likely yes but not 100% sure, unless:
> 1) The threads do not interfere each other
> 2) You did a CPU affinity for each your thread.
Yes. The threads will not share data and will not interact in any way.
> what you can do is the following pattern:
>
> 1) Insert your jobs in a thread safe container (or do a wrapper around
> an std one).
> 2) Launch *all* your threads giving them a reference to the above
> container.
All at once? What if I have millions of tasks rather than a few? I want to be working on 2 tasks all the time. If my queue is not empty, then as a thread ends, it sees there are more tasks in the queue and gets one.
> 3) Then each thread have to do in the main loop (pseudo code here):
> Job* job = NULL;
> while( job = container.extract_job() ) {
> work on job;
Hotmail: Trusted email with Microsoft’s powerful SPAM protection. Sign up now.