what is the difference between multitasking and
multithreading?

Answer Posted / sonika

Multithreading
Up to now, we have talked about multiprogramming as a way to allow multiple programs being resident in main memory and (apparently) running at the same time. Then, multitasking refers to multiple tasks running (apparently) simultaneously by sharing the CPU time. Finally, multiprocessing describes systems having multiple CPUs. So, where does multithreading come in?
Multithreading is an execution model that allows a single process to have multiple code segments (i.e., threads) run concurrently within the “context” of that process. You can think of threads as child processes that share the parent process resources but execute independently. Multiple threads of a single process can share the CPU in a single CPU system or (purely) run in parallel in a multiprocessing system
Why should we need to have multiple threads of execution within a single process context?
Well, consider for instance a GUI application where the user can issue a command that require long time to finish (e.g., a complex mathematical computation). Unless you design this command to be run in a separate execution thread you will not be able to interact with the main application GUI (e.g., to update a progress bar) because it is going to be unresponsive while the calculation is taking place.
Of course, designing multithreaded/concurrent applications requires the programmer to handle situations that simply don’t occur when developing single-threaded, sequential applications. For instance, when two or more threads try to access and modify a shared resource (race conditions), the programmer must be sure this will not leave the system in an inconsistent or deadlock state. Typically, this thread synchronization is solved using OS primitives, such as mutexes and sempaphores.

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is getclass () getname () in java?

681


If a method is declared as protected, where may the method be accessed?

534


What is the difference between the reader/writer class hierarchy and the inputstream/outputstream class hierarchy in java programming?

613


What is a variable declaration?

527


What are the types of strings?

565






What are the different tags provided in jstl?

553


If we allocate the memory using 'new' & de-allocated using 'free' then what will happen?

596


What is the biggest integer?

554


How do you create a sop?

529


What is the purpose of an interface?

557


what is object-oriented programming in java?

589


Can we write method inside a method in java?

523


What does those terms actually mean included in the j.d.k i.6?

1605


What is a Presistent Object?

645


How do you find the absolute value?

563