Multithreading ? Why?

Need help with C, C++, perl, python, etc?

Multithreading ? Why?

Postby reiko » 2015-09-23 18:58

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 [url]http://www.experts-exchange.com/articles/1635/Multithreading-Why-and-When.html
[/url] yet i still see people use them
reiko
 
Posts: 100
Joined: 2015-09-02 22:40

Re: Multithreading ? Why?

Postby stevepusser » 2015-09-23 19:43

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.
The MX Linux repositories: Backports galore! If we don't have something, just ask and we'll try--we like challenges. New packages: Krita 3.3.2.1, Pale Moon 27.6.0, Audacity 2.2.0, mpv 0.27.0, Corebird 1.7.1, Firefox 57.0, SMPlayer 17.11.2
User avatar
stevepusser
 
Posts: 8904
Joined: 2009-10-06 05:53

Re: Multithreading ? Why?

Postby dasein » 2015-09-23 21:03

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
dasein
 
Posts: 7775
Joined: 2011-03-04 01:06
Location: Terra Incantationum

Re: Multithreading ? Why?

Postby GarryRicketson » 2015-09-23 22:04

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/why-johnny-cant-write-multithreaded-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.
"What we expect you have already Done"

Before doing anything, read the Debian documentation:
Debian Documentation
How to ask the smart way
Debian Foro Español
======================
For the Birds
User avatar
GarryRicketson
 
Posts: 4363
Joined: 2015-01-20 22:16
Location: Durango, Mexico

Re: Multithreading ? Why?

Postby BowCatShot » 2015-09-24 02:17

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 [url]http://www.experts-exchange.com/articles/1635/Multithreading-Why-and-When.html
[/url] 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.
BowCatShot
 
Posts: 964
Joined: 2006-07-15 12:08

Re: Multithreading ? Why?

Postby tomazzi » 2015-09-25 11:04

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
tomazzi
 
Posts: 730
Joined: 2013-08-02 21:33

Re: Multithreading ? Why?

Postby stevepusser » 2015-09-25 18:16

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.
The MX Linux repositories: Backports galore! If we don't have something, just ask and we'll try--we like challenges. New packages: Krita 3.3.2.1, Pale Moon 27.6.0, Audacity 2.2.0, mpv 0.27.0, Corebird 1.7.1, Firefox 57.0, SMPlayer 17.11.2
User avatar
stevepusser
 
Posts: 8904
Joined: 2009-10-06 05:53


Return to Programming

Who is online

Users browsing this forum: No registered users and 3 guests

fashionable