0% found this document useful (0 votes)
2 views10 pages

1 Multithreaded Programming Introduction

Uploaded by

mounica
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views10 pages

1 Multithreaded Programming Introduction

Uploaded by

mounica
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Module – 4

Multi threaded Programming, Event Handling

OOC
4th Sem, ‘B’ Div
2016-17
Prof. Mouna M. Naravani
Multithreaded Programming
Multitasking
➢ Executing several tasks simultaneously is called Multi tasking.
➢ 2 types of Multi tasking:
1. Process Based Multitasking
➢ Process: A program that is executing.
➢ Executing several tasks simultaneously where each task is a separate, independent
process is called “Process Based Multitasking”.
➢ Ex: Writing a Java program in a text editor, listening to music, downloading a file from
internet, Facebook chat.
➢ All these tasks are executing simultaneously and are independent of each other.
➢ It is best suitable at O S level.
2. Thread Based Multitasking

➢ Executing several tasks simultaneously where each task is a separate, independent part
of the same program is called “Thread Based Multitasking”.
➢ Ex: Text editor: performing editing as well as printing.
➢ It is best suitable at Programmatic level.
➢ Java provides built in support for Thread Based Multitasking by providing rich
library.
➢ Applications: Video games, Multi media graphics, Servers.

➢ Thread: A flow of execution.


➢ Each independent part of a program is called thread.
➢ For every thread a job(work) will be there.
NOTE:
Let it be Process based or Thread based, the main objective of multi tasking is to
reduce response time and improve performance of the system.
Difference between Process based and Thread based multi tasking

Process Based Thread Based


Heavyweight tasks because they require Lightweight because they share the same
their own separate address spaces address space.

Interprocess communication is expensive Interthread communication is inexpensive.


and limited.

Context switching from one process to Context switching from one thread to the
another is costly. next is low cost.
Benefits of Multi Threading
➢ Multithreading enables you to write very efficient programs that make maximum use of
the CPU, because idle time can be kept to a minimum.
➢ Enable programmers to do multiple things at the same time.
➢ Programmers can divide a large program into multiple independent threads and execute
them in parallel which will eventually increase program execution speed.
➢ Improved performance and concurrency.
➢ Simultaneous access to multiple applications.
References

➢ Herbert Schildt, “The Complete Reference, JAVA”, 7th ed

You might also like