Quote:
Originally Posted by brackett
According to Wikipedia, multi-processing refers to using multiple CPUs to execute simultaneously - which is where this discussion started. Without multiple CPUs (or cores), you're really just switching tasks on a single CPU.
The discussion is, I think, when and whether multi-threading is advantageous. My argument is that it's actually *not* that much of an advantage now (because you're not "multi-processing", since 95+% of desktops are single core) but that it will become increasingly important as dual and quad cores become common place. Also, there's both a (slight) performance penalty, and a increased maintenance cost with multithreaded code. All of that needs to be considered..
|
Well yes. I said 'might better be described as multi-processing'. Not 'this is multi-processing'.
When you say that multi-threading is not faster on a single CPU. Not faster than what? I couldn't give you an example of a program that uses multiple threads that could be better written in a single thread; because as I said before, you resort to polling or you start rejecting input.
Imagine writing a web-browser in a single thread. Aside from the size of the code-base, how would you handle connections to multiple web-pages without polling? My point is, that in single core processors, threads allow programs to abstract away the difficulty of scheduling multiple jobs. You couldn't write a faster single threaded version. So, no, multi-threading is not slower on single core CPU's (unless you mis-use them).
Quote:
Originally Posted by brackett
If there is no need for locking on shared data, somebody should tell the Java folks that the synchronized keyword is no longer needed.
|
Okay, the way I said that wasn't particuarly clear. They are required, but thread context switching is exceptionally minimal compared to process context switching. Despite the cost there's no better alternative, so its not an issue.
Quote:
Originally Posted by brackett
My point, however, that multi-threading is *not* (generally) faster on a single CPU system remains.
|
It's slower where it isn't needed. But in programs that require multiple connections (or similar) it isn't possible to do it more efficient any other way.