unit v concurrent programming

33
1 CONCURRENT PROGRAMMING 1)Multi-threaded programming Multitasking in your operating system: the ability to have more than one program working at what seems like the same time. For example, you can print while editing or downloading your email. Nowadays, you are likely to have a computer with more than one CPU, but the number of concurrently executing processes is not limited by the number of CPUs. The operating system assigns CPU time slices to each process, giving the impression of parallel activity. What is the difference between multiple processes and multiple threads?  The essential difference is that while each process has a complete set of its own variables, threads share the same data. However, shared variables make communication between threads more efficient and easier to program than interprocess communication.  Moreover, on some operating systems, threads are more “lightweight” than processesit takes less overhead to create and destroy individual threads than it does to launch new processes. (For example, a browser should be able to simultaneously download multiple images. A web server needs to be able to serve concurrent requests. Graphical user interface (GUI)  programs have a separate thread for gathering user interface events from the host operating environment.) (Multithreading changed dramatically in Java SE 5.0, with the addition of a large number of classes and interfaces that provide high-quality implementations of the mechanisms that most application programmers will need.)  Multithreading has several advantages over Multiprocessing such as;  Threads are lightweight compared to processes  Threads share the same address space and therefore can share both data and code  Context switching between threads is usually less expensive than between p rocesses  Cost of thread intercommunication is relatively low that that of process intercommunication  Threads allow different tasks to be performed concurrently.

Upload: prkshjs

Post on 05-Apr-2018

233 views

Category:

Documents


0 download

TRANSCRIPT

7/31/2019 Unit v Concurrent Programming

http://slidepdf.com/reader/full/unit-v-concurrent-programming 1/33

7/31/2019 Unit v Concurrent Programming

http://slidepdf.com/reader/full/unit-v-concurrent-programming 2/33

7/31/2019 Unit v Concurrent Programming

http://slidepdf.com/reader/full/unit-v-concurrent-programming 3/33

7/31/2019 Unit v Concurrent Programming

http://slidepdf.com/reader/full/unit-v-concurrent-programming 4/33

7/31/2019 Unit v Concurrent Programming

http://slidepdf.com/reader/full/unit-v-concurrent-programming 5/33

7/31/2019 Unit v Concurrent Programming

http://slidepdf.com/reader/full/unit-v-concurrent-programming 6/33

7/31/2019 Unit v Concurrent Programming

http://slidepdf.com/reader/full/unit-v-concurrent-programming 7/33

7/31/2019 Unit v Concurrent Programming

http://slidepdf.com/reader/full/unit-v-concurrent-programming 8/33

7/31/2019 Unit v Concurrent Programming

http://slidepdf.com/reader/full/unit-v-concurrent-programming 9/33

7/31/2019 Unit v Concurrent Programming

http://slidepdf.com/reader/full/unit-v-concurrent-programming 10/33

7/31/2019 Unit v Concurrent Programming

http://slidepdf.com/reader/full/unit-v-concurrent-programming 11/33

7/31/2019 Unit v Concurrent Programming

http://slidepdf.com/reader/full/unit-v-concurrent-programming 12/33

7/31/2019 Unit v Concurrent Programming

http://slidepdf.com/reader/full/unit-v-concurrent-programming 13/33

7/31/2019 Unit v Concurrent Programming

http://slidepdf.com/reader/full/unit-v-concurrent-programming 14/33

7/31/2019 Unit v Concurrent Programming

http://slidepdf.com/reader/full/unit-v-concurrent-programming 15/33

7/31/2019 Unit v Concurrent Programming

http://slidepdf.com/reader/full/unit-v-concurrent-programming 16/33

7/31/2019 Unit v Concurrent Programming

http://slidepdf.com/reader/full/unit-v-concurrent-programming 17/33

7/31/2019 Unit v Concurrent Programming

http://slidepdf.com/reader/full/unit-v-concurrent-programming 18/33

7/31/2019 Unit v Concurrent Programming

http://slidepdf.com/reader/full/unit-v-concurrent-programming 19/33

7/31/2019 Unit v Concurrent Programming

http://slidepdf.com/reader/full/unit-v-concurrent-programming 20/33

7/31/2019 Unit v Concurrent Programming

http://slidepdf.com/reader/full/unit-v-concurrent-programming 21/33

7/31/2019 Unit v Concurrent Programming

http://slidepdf.com/reader/full/unit-v-concurrent-programming 22/33

7/31/2019 Unit v Concurrent Programming

http://slidepdf.com/reader/full/unit-v-concurrent-programming 23/33

7/31/2019 Unit v Concurrent Programming

http://slidepdf.com/reader/full/unit-v-concurrent-programming 24/33

7/31/2019 Unit v Concurrent Programming

http://slidepdf.com/reader/full/unit-v-concurrent-programming 25/33

7/31/2019 Unit v Concurrent Programming

http://slidepdf.com/reader/full/unit-v-concurrent-programming 26/33

7/31/2019 Unit v Concurrent Programming

http://slidepdf.com/reader/full/unit-v-concurrent-programming 27/33

7/31/2019 Unit v Concurrent Programming

http://slidepdf.com/reader/full/unit-v-concurrent-programming 28/33

7/31/2019 Unit v Concurrent Programming

http://slidepdf.com/reader/full/unit-v-concurrent-programming 29/33

7/31/2019 Unit v Concurrent Programming

http://slidepdf.com/reader/full/unit-v-concurrent-programming 30/33

7/31/2019 Unit v Concurrent Programming

http://slidepdf.com/reader/full/unit-v-concurrent-programming 31/33

7/31/2019 Unit v Concurrent Programming

http://slidepdf.com/reader/full/unit-v-concurrent-programming 32/33

7/31/2019 Unit v Concurrent Programming

http://slidepdf.com/reader/full/unit-v-concurrent-programming 33/33