Multithreading in Java
1
What is Thread?
A thread is a lightweight sub-process, the smallest unit of
processing. This is the path followed when executing a
program. A thread is an independent path of execution within
a program. All Java programs have at least one thread.
2
What is Multithreading?
Multithreading is a concept of programming where a program
is divided into two or more threads or sub-process which are
executed at the same time in parallel by sharing their
processing resources.
A program that contains multiple flows of control is known as
multithreaded program.
3
Life cycle of a Thread
4
Example of a Multithreaded program
5
Example(continue)
6
Example(continue)
7
Example(continue)
8
Example(continue)
9
Advantages of Multithreading in Java
• We can perform multiple operations at the same time and it does not
block the user, because threads are independent.
• Simple programming diagram and parallel execution system.
• Useful for improving the responsiveness of the user interfaces.
• Improves the performance of complex applications.
• Reduces maintenance costs.
• Better use of CPU resource.
10
11

Multithreading in java

  • 1.
  • 2.
    What is Thread? Athread is a lightweight sub-process, the smallest unit of processing. This is the path followed when executing a program. A thread is an independent path of execution within a program. All Java programs have at least one thread. 2
  • 3.
    What is Multithreading? Multithreadingis a concept of programming where a program is divided into two or more threads or sub-process which are executed at the same time in parallel by sharing their processing resources. A program that contains multiple flows of control is known as multithreaded program. 3
  • 4.
    Life cycle ofa Thread 4
  • 5.
    Example of aMultithreaded program 5
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
    Advantages of Multithreadingin Java • We can perform multiple operations at the same time and it does not block the user, because threads are independent. • Simple programming diagram and parallel execution system. • Useful for improving the responsiveness of the user interfaces. • Improves the performance of complex applications. • Reduces maintenance costs. • Better use of CPU resource. 10
  • 11.