Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,153,238 members, 7,818,811 topics. Date: Monday, 06 May 2024 at 05:04 AM

Can Someone Give A Summary Of Multithreaded Programming - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Can Someone Give A Summary Of Multithreaded Programming (1124 Views)

(2) (3) (4)

(1) (Reply) (Go Down)

Can Someone Give A Summary Of Multithreaded Programming by bigboyslim(m): 3:50pm On May 26, 2011
Candylips, logica, kobojunkie, other gurus,

Can anyone give a high level overview of multithreaded programming. Please include an example of when it could be useful in an app.

Thanks
Re: Can Someone Give A Summary Of Multithreaded Programming by Afritelly: 4:08pm On May 26, 2011
On what programming langugae do you need it?
Re: Can Someone Give A Summary Of Multithreaded Programming by bigboyslim(m): 4:15pm On May 26, 2011
I just wanted to grasp the concept. I don't think language should matter but if it does, then Java will do for me. .

Thanks
Re: Can Someone Give A Summary Of Multithreaded Programming by Afritelly: 4:36pm On May 26, 2011
Ok, basic concept of multithreading is just to allowing access to two or more threads.

Then,

[b]What Is a Thread?

All programmers are familiar with writing sequential programs. You've probably written a program that displays "Hello World!", or sorts a list of names, or computes a list of prime numbers. These are sequential programs: each has a beginning, an execution sequence, and an end. At any given time during the runtime of the program there is a single point of execution.

A thread is similar to the sequential programs described above: a single thread also has a beginning, an end, a sequence, and at any given time during the runtime of the thread there is a single point of execution. However, a thread itself is not a program. It cannot run on its own, but runs within a program.
Definition: A thread is a single sequential flow of control within a program.

There is nothing new in the concept of a single thread. The real hoopla surrounding threads is not about a single sequential thread, but rather about the use of multiple threads in a single program all running at the same time and performing different tasks.

The HotJava Web browser is an example of a multithreaded application. Within the HotJava browser you can scroll a page while it's downloading an applet or image, play animation and sound concurrently, print a page in the background while you download a new page, or watch three sorting algorithms race to the finish. You are used to life operating in a concurrent fashion, so why not your browser?

Some texts use the name lightweight process instead of thread. A thread is similar to a real process in that a thread and a running program are both a single sequential flow of control. However, a thread is considered lightweight because it runs within the context of a full-blown program and takes advantage of the resources allocated for that program and the program's environment.

As a sequential flow of control, a thread must carve out some of its own resources within a running program. (It must have its own execution stack and program counter for example.) The code running within the thread works only within that context. Thus, some other texts use execution context as a synonym for thread.
[/b]

http://www4.ncsu.edu/~rhee/clas/csc495j/MultithreadedProgrammingGuide_Solaris24.pdf
Re: Can Someone Give A Summary Of Multithreaded Programming by Shimao(m): 6:38pm On May 26, 2011
Multithreading is simply running many tasks at the same time. Computers used to have only 1 processor and programs are instructions for the processor to execute and processors can only do things one at a time. So how do you get to play audio, type, download and do all sorts at the same time? Well, the system creates threads which are distinct lines of execution of codes for each task and shares the processor time between available threads. This is called context switching and occurs so fast that the user never notices. Now multithreading used to be a system level thing and with older programming languages, you'll have to load system specific libraries to accomplish it. However multithreading is built into java and allows your program remain uniform accross platforms. Multithreading introduces its own problem because its like you have a group of people that want to use the same thing, so you have to control access and guarantee the integrity of the shared resource. Multithreading can be used to increase performance of applications and also efficiently use resources.
Re: Can Someone Give A Summary Of Multithreaded Programming by bigboyslim(m): 2:01am On May 27, 2011
Thanks for the responses so far.
Re: Can Someone Give A Summary Of Multithreaded Programming by Seun(m): 2:02am On May 27, 2011
Interesting

(1) (Reply)

Networking Or Database..pls Help Me Out. / Building For Android And Blackberry In C# / Simple Python Challenge

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 52
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.