Why aren't there more multithreaded programs/applications?

Status
Not open for further replies.

Hemroid

Distinguished
Feb 25, 2010
2
0
18,510
I'm just wondering why companies aren't making multithreaded programs. I've been doing some reading and people are saying it's just like learning a 2nd language.

Don't get me wrong, I only know C, I'm just wondering.
 
Here's an excercise to help you understand multi-threaded programming:

1. Open Task Manager.

2. Open the "View/Select Columns" menu.

3. Tick the box next to "Threads".

4. Click "OK".

5. Examine display, paying particular attention to the column "Threads".

Now - what was the question again?
 

Hemroid

Distinguished
Feb 25, 2010
2
0
18,510
You're probably going to think I sound like a jackass, but I don't use Windows right now - W7 was bugging out (re-installed it twice, luckily it's free through MSDNAA). I went into System Monitor (Ubuntu 9.10), and tried to do the same thing, but there was no similar choice.

I'll take it from your response that their are, indeed, several processes that utilize multi-threaded programming?

This wasn't a question about why companies suck and why they don't know how to do it. I have noticed that only 1 core (on my core 2 duo) goes up to 100%, while the other sits around 10% - if that. I'm not going to get a new pc for a year or so (mine is on it's 4th year), and I know that it's a little outdated, so it's sure as hell not going to be "fast", I didn't really care about speed at the time, but now that my computer is old, it would be nice if both cores were utilized when I open things (since Ubuntu is now freezing up 3-4 times/day due to the processor being at 100%).
 
Most Windows programs are fairly highly threaded. Doing that exercise on my Windows 7 setup shows no programs at all with only one thread. Because threads are not implemented so efficiently on Linux, and processes more so, programs have more of a tendency to be implemented as single-threaded processes on Linux.

It's probably true that only one process, or even thread, at a time is utilizing a high percentage of CPU time, but that doesn't mean that the programs are not highly threaded. 99.9% of the threads on a system will be blocking waiting for some event at any given instant.
 

Zenthar

Distinguished
First, not every task can be multithreaded. The classic real-life example is that it doesn't take 1 month for 9 women to make a child. Secondly, multithreading adds lots of complexities, mostly related to resource locking and synchronization. Just take a look at basic multithreading examples found around, they are relatively complex for trivial functionalities.

As mindless728 said, try to make a simple multithreaded demo app in C or even Java and see how "fun" it is. You can try trivial implementation like the Dinning philosophers or Producer-consumer.
 

Tom Griffin

Distinguished
Sep 29, 2009
78
0
18,640
A simple application you can write in C is a Que based delegation of various tasks. Wont get the same stuff as pre-emptive multi-tasking. But you will run into Zenthar's problem real quick.

You can however, thread all day long with store and forward queues basing you application of like a centralized messenger with multiple servers delegating tasks.

Simply put; write a traffic cop that directs traffic in NYC when the street lights have gone out; you go do this; hey idiot you do that, take a peek see if they did it, report the results. With 50 or so cars stacked up and pedestrians messing with the queue.
 

Clintonio

Distinguished
Apr 10, 2008
325
0
18,780


I attempted it on Windows and only around 10% of my processes use only one thread, and they're all auto-updaters or basic monitors of some sort. Apache is second only to Windows system idle process.

But as people say, not everything can, or needs to be, multithreaded.
 
Status
Not open for further replies.