English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

2007-01-18 06:00:51 · 6 answers · asked by soumitrachand 1 in Computers & Internet Programming & Design

6 answers

I would disagree with some of the points cited by people who have already answered the question. Multi threading involves a program to split itself into two or more pseudo-simultaneously running tasks. How internally threads function; is dependent on OS implementation to handle the process and threads. but in general, the way that a thread is created and shares its resources is different from the way a process does. multi-threading generally occurs by time slicing, a single processor switches between different threads, the processing is not simultaneous, for the single processor is only really doing one thing at a time.
Processes are typically independent, carry considerable state information, have separate address spaces. Multiple threads, share the state information of a single process, and share memory and other resources directly.
@ Pfo :-
OS does not maintain the pool of threads usually, this would be handled by the application itself.

@ AM :-
Multithreading would not increase the performance of your application unless your application is running on multiple processors. Multi-threaded program allows it to operate faster on computer systems that have multiple CPUs, CPUs with multiple cores, or across a cluster of machines.

@ AM :-
Sub dividing a program in to smaller pieces is not multi-threading. They are termed functions/sub routines/ methods different language term this process differently

@ roooya :-
Most of the applications written are multi-threaded application. The browser that you use, MS word, Web servers, Port sniffers etc.

Hope this helps

--
Ck
http://www.gfour.net

2007-01-19 00:56:49 · answer #1 · answered by KingPin 3 · 0 0

Most code written today is sequential. What do we mean by the term sequential or serialized? Simply put, code is executed one instruction after the next in a monolithic fashion, with no regard to the many possible resources available to the program. Overall performance can be serverely degraded if the program performs a blocking call.

Why is it that most programs are sequential? One guess could be the relative dominance of uniprocessing machines available to programmers. Multithreading a program on a uniprocessor machine in most cases does not yield enough performance gains to merit days, weeks, or months worth of work to thread code. Another guess is that most of us think in a sequential manner. Parallelizing our thoughts does not come naturally nor is it an easy task.

However, times have changed and many papers have been written on multithreading. Some advocate the use of threads, while others do not. With the increasing popularity of Symmetric-Multiprocessing machines, programming multithreaded code is a skill worth learning.

We will dive into the world of threads with some a little bit of "theory" first. We will examine thread synchronization primitives and then a tutorial on how to use POSIX pthreads. Finally, we will finish off with thread performance and a brief overview of multiprocess programming.

2007-01-18 06:11:21 · answer #2 · answered by roooya 2 · 0 0

If we view a program as a set of steps lets just use ABC and D a simple program will do A then B then C and finally D and then stop execution. A multi-threaded program can start with A, and execute B, C, and D at the same time. So it could potentially have A then B,C, and D can finish up in any order before it ends execution.

An example of multi-threaded programming is a web server. You have the main program listening for Internet connections and then a thread is "spawned" to handle the request so that multiple Internet request can be handled at the same time.

Hope that helps

RJ

2007-01-18 06:12:44 · answer #3 · answered by Anonymous · 0 0

A multi-threaded program consists of several threads, each of which is a unit of execution. Typically, most simple windows apps are single-threaded. You should know that a single core processor, and therefore each processor core, can only do 1 thing at a time. So in order to get a multi-tasking operating system that is capable of running multiple different apps, they must use threads. Part of the Windows OS is the scheduler, a program that runs in the background and maintains a pool of threads. Every so often, whatever program or thread is running gets interrupted so the scheduler can decide what to do next. It is here that it can switch the current thread and force the previous thread to sleep.

This is useful if, for example, your program has a user interface that you want to seem responsive when it does a time consuming task. One thread can manage the UI and windows message loop, the other can chug away at the CPU intensive process and maybe update a status bar showing the progress on its task.

2007-01-18 06:07:53 · answer #4 · answered by Pfo 7 · 0 0

a multi threaded program is very much useful in multitask programs,that means a program designed to do many functions and invloves many subprograms.

in simple a multithreaded program is a program to link many programs in to a common main program and to link all the programs

it is useful in programs like arithmatic operations and etc....

2007-01-18 06:13:56 · answer #5 · answered by praveen M 1 · 0 0

a program that we normally write(simple ones) are single thread,that means it is executed step by step.
now consider this:
a program being subdivided into even smaller subprograms(called threads); this has the advantage that program execution is faster
at the primary level all programs r divided into threads which are executed by the processor...
in multithreading u divided ur programs explicitly into threads that r executed...this ensures that program execution is faster as multithreading help simulate parallel processing....

2007-01-18 06:11:19 · answer #6 · answered by AM 3 · 0 0

fedest.com, questions and answers