When can you determine if you are using too many threads? Assuming I have complete control and mutex locks and what not, when does it slow my program down, rather than speed it up by splitting up processing into sectons and passing between FIFO queues. Thanks.

Recommended Answers

All 3 Replies

If running MS-Windows check Task Manager to see CPU time in use -- if its approaching 90% then you have too many threads.

ok, thanks. Also, If I am passing a class into my thread function, and use the same class in a different thread, but a different function of the class, can they operate in parellel, or would I have to wrap in mutex locks or make 2 different classes? Thanks.

It's not the functions of the class you have to worry about, it's the instances.

Two threads could work on two separate instances of the class, and call the same functions. So long as the class member functions themselves were reentrant (no static / global data for example).

Well if you've got lots of processing to do, then you start to lose when you exceed the number of cores you have on your processor.
Context switching and message passing just become useless and unproductive overhead at that point.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.