MULTITHREADING PROGRAMMING MULTITASKING It is same as multithreading

  • Slides: 9
Download presentation
MULTITHREADING PROGRAMMING

MULTITHREADING PROGRAMMING

MULTITASKING It is same as multithreading. Multitasking in java is a process of executing

MULTITASKING It is same as multithreading. Multitasking in java is a process of executing multiple tasks simultaneously. Multithreading and Multiprocessing both are used to achieve multitasking. In multitasking we have two methods. Process based Multitasking(Multiprogramming) Thread based Multitasking(multithreading)

Process based Multitasking(Multiprogramming) Each process has an address in memory. A process is a

Process based Multitasking(Multiprogramming) Each process has an address in memory. A process is a heavyweight. Cost of communication between the process is high. Thread based Multitasking(multithreading) Threads share the same address space A thread is lightweight. Cost of communication between the thread is low

ADVANTAGES OF MULTITHREAD time. It doesn’t block the user because threads are independent. The

ADVANTAGES OF MULTITHREAD time. It doesn’t block the user because threads are independent. The user can perform many operation together, so it saves Threads are independent, so it doesn’t affect other threads.

SINGLE THREADED PROGRAM Single thread used to perform only one task. A thread is

SINGLE THREADED PROGRAM Single thread used to perform only one task. A thread is a lightweight sub-process, the smallest unit of processing. class ABC { …. public void run(. . ) { …. . } }

MULTITHREADING PROGRAMMING Multithreading in java is a process of executing multiple threads simultaneously. Its

MULTITHREADING PROGRAMMING Multithreading in java is a process of executing multiple threads simultaneously. Its also called as multitasking.

A Multithreaded Program Main Thread start Thread A start Thread B Threads may switch

A Multithreaded Program Main Thread start Thread A start Thread B Threads may switch or exchange data/results 7 Thread C

Threads Concept Multiple threads on multiple CPUs Multiple threads sharing a single CPU 8

Threads Concept Multiple threads on multiple CPUs Multiple threads sharing a single CPU 8

THANK YOU

THANK YOU