5 ms·
> What's the real reason for using threads today? Hahaha, good one ... oh, wait. Are you serious? The real reasons are the same as they were, including separa
by huhtenberg 12y ago
> What's the real reason for using threads today?
Hahaha, good one ... oh, wait. Are you serious?
The real reasons are the same as they were, including separation of GUI and non-GUI processing in desktop apps, dispersal of bulk work (both computational and operational) across several cores, wrapping of blocking calls to make them asynchronous/cancellable, etc.
What is it that changed today that made you think that well-established multi-threading patterns are no longer relevant?
- jokoon 12y ago> What is it that changed today that made you think that well-established multi-threading patterns are no longer relevant? Not patterns, but usage. I thought things like OpenCL would have made multi core CPU less relevant for intensive calculations, since GPUs are so much more powerful when you need to execute tasks at the same time. And since processors were single threaded for a very long time, I was wondering what were threads being used for before multi core CPUs, and how did it really change things for GUIs. I mean threads were not really useful on single cores, were they ? So it just seems to me that threads are just being made useful since multi cores CPUs, not really before. And unless you really need to take full advantage of the CPU when you're making a single app, your app is not always the single one being ran, cores can also run other apps not being threads. One simple software might not always need to take advantage of threads, unless it's a big software like a commercial 3d game.
- rayiner 12y agoGPUs are not suitable for many types of calculations.
- jokoon 12y agoI would be curious to have some examples. Number crunching is almost always parallelizable. Computing is not always calculation. As long as you can simplify your program as a set of input/output models, OpenCL/CUDA will help a lot. Of course it's not a silver bullet, so often one might have to reorganize the problem to have a better performing solution. The more you can tweak an algorithm to fit inside a set of stricter constraint, the better it will perform on a GPU. Of course, if you have a hard problem, it's always better to be able to build hardware which targets a particular problem for optimal performance. Maybe I'd be more interested in multithreading when CPU will have at least 16 or 32 cores. 4 or 8 cores is not a lot.
- Gurkenmaster 12y ago>I mean threads were not really useful on single cores, were they ? Every application you run has at least one thread or how did you think the main function is run? You won't be able to run multiple applications without multi-tasking. >how did it really change things for GUIs. GUI applications are usually single threaded. This means if you run anything blocking in that thread the entire application will freeze. The GUI thread can still continue if you run your blocking task in a worker thread. The OS sheduler will take care of your threads even if you have only a single core to make sure everything remains responsive. (yes they were clearly talking about websites for mobile devices /sarcasm) The only advantage of parallelism compared to concurrency is more performance.
- jokoon 12y ago> You won't be able to run multiple applications without multi-tasking. But that doesn't mean you really need to make use of multi threading in your program, since the OS is already doing it. > The only advantage of parallelism compared to concurrency is more performance. Only if your program can be parallelized. And even if you do manage to parallelize it, in the best case, you'll only get a 4X or 8X performance increase, which is not a big order of magnitude.