Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Multithreading ? Why?

Programming languages, Coding, Executables, Package Creation, and Scripting.
Post Reply
Message
Author
reiko
Posts: 100
Joined: 2015-09-02 22:40

Multithreading ? Why?

#1 Post by reiko »

i read some articles and lectures about multithreading and concurrency programming and i still have hard time to see what
they good for. it seems they dont add any functionality to the programmer and i cant think of a reason why to use them
especially when i read this http://www.experts-exchange.com/article ... When.html yet i still see people use them

User avatar
stevepusser
Posts: 12930
Joined: 2009-10-06 05:53
Has thanked: 41 times
Been thanked: 71 times

Re: Multithreading ? Why?

#2 Post by stevepusser »

The answer is easily available with a little web search.

Consider the prevalence of multicore processors.
Last edited by stevepusser on 2015-09-24 00:58, edited 1 time in total.
MX Linux packager and developer

User avatar
dasein
Posts: 7680
Joined: 2011-03-04 01:06
Location: Terra Incantationum

Re: Multithreading ? Why?

#3 Post by dasein »

reiko wrote:...i still have hard time to see what [are] they good for... i cant think of a reason why to use them...
Then it's a safe bet you've never had to write time-sensitive code.

Purely as an intellectual exercise, challenge yourself to think up at least 5 applications/domains where parallel processing would be helpful (ideally without a Web search).

User avatar
GarryRicketson
Posts: 5644
Joined: 2015-01-20 22:16
Location: Durango, Mexico

Re: Multithreading ? Why?

#4 Post by GarryRicketson »

There are a lot of results on this doing some basic searches, but I like this one:
From:http://www.answers.com/Q/Why_you_need_multithreadingNot having multithreading is like only having one arm and one gram of brain tissue. Multithreading is essential to computer application operation.

This one is pretty good also,..http://blog.smartbear.com/programming/w ... -programs/
This is comparable to the old "argument" about using the "goto" command in qbasic, a very controversial subject, and popular question way back then often posted by "trolls", "Should I use the goto command in this program ? " followed with some short script , using the goto command. Knowing very well, a long drawn out argument would follow between various programmers, as to if the goto command should be used or not.
The goto command is a very use full command, but there are times when it should not be used as well, especially in larger programs.
-------------
edited: Please don't get me wrong, I am not saying you asked this as a "troll" question, I did the same thing, years ago, when I honestly was just curious, and asked about the goto command, it started a huge argument, :mrgreen: , but the best answers were similar, some told me to do some searches, and later with some experience I could see when it was easiest and best to use the 'goto' command and when not to.(just saying)
----------
The same would apply to "multi threading", especially on smaller, more simple programs, there might not be any need to use it, on larger programs, there is more need.
After all said and done it is mostly dependent on the programmer, and if they have the ability to fully understand how to use "multi threading", when to use it, and when not too.
it seems they dont add any functionality to the programmer and i cant think of a reason why to use them
If you are the "programmer", you do not have to use multi threading, if you do not want to, but that may limit the kind of programs you can create.Probably the reason you can not see any reason to use multi threading, is you are not that advanced, so at this point no need to use it.

BowCatShot
Posts: 959
Joined: 2006-07-15 12:08

Re: Multithreading ? Why?

#5 Post by BowCatShot »

reiko wrote:i read some articles and lectures about multithreading and concurrency programming and i still have hard time to see what
they good for. it seems they dont add any functionality to the programmer and i cant think of a reason why to use them
especially when i read this http://www.experts-exchange.com/article ... When.html yet i still see people use them
The most obvious use of multithreading is in real time data communications applications where you want your application to operate in full duplex mode. That is you want to be able to send and receive data at the same time. So you would create separate threads for the read and write operations.

Another example is where you're sorting a large data file while you're simultaneously sitting on blocked terminal reads from one or more users. You would want the blocking to take place in separate threads.

Most real time embedded systems employ multi threads.

tomazzi
Posts: 730
Joined: 2013-08-02 21:33

Re: Multithreading ? Why?

#6 Post by tomazzi »

BowCatShot wrote:Most real time embedded systems employ multi threads.
...and most of real time applications are multi-threaded AND event-based (hardware interrupts).

The article mentioned by GarryRicketson is really good, but I think that the author should put more pressure on 2 fundamental aspects of threads:
1. Threads allow to use separate context for each task in the application - this makes life a lot easier and makes programs faster.
2. Scalability - properly written multi-threaded program scales up its performance proportionally to the number of CPUs, without changing a single line of code.

Regards.
Odi profanum vulgus

User avatar
stevepusser
Posts: 12930
Joined: 2009-10-06 05:53
Has thanked: 41 times
Been thanked: 71 times

Re: Multithreading ? Why?

#7 Post by stevepusser »

For most end users, benefits can be seen in using multiple threads (thus cores) in video playback and transcoding, such as for h.264 codecs. Also for compiling, so you can throw linux kernel source at a machine with a large number of cores and have a kernel in a few seconds. Most Debian source packages support parallel builds, such as anything using Qt.
MX Linux packager and developer

Post Reply