DEV Community

velvizhi Muthu
velvizhi Muthu

Posted on

Module 5-Multithreading

01.What is the Multithreading?
A thread is a lightweight sub-process, the smallest unit of processing.
Multiprocessing and multithreading, both are used to achieve multitasking.

02.Advantages of Java Multithreading?

  1. Enhanced Performance
  2. Parallel Execution
  3. Improved GUI Responsiveness
  4. Better CPU Utilization
  5. Reduced Development Time

03.Disadvantages of Multithreading?

  1. Complexity
  2. Synchronization issues
  3. Debugging difficulty
  4. Resource Overhead

04.What is Thread in Java?

  1. A thread is a lightweight subprocess, the smallest unit of processing.
  2. It is a separate path of execution.
  3. Threads are independent.
  4. If an exception occurs in one thread, it does not affect other threads.
  5. It uses a shared memory area.

05.What is Thread class?

  1. Thread class to achieve thread programming.
  2. The Thread class provides constructors and methods to create and perform operations on a thread.
  3. Thread class extends the Object class and implements the Runnable interface.

06.Thread class method?
The Thread class in Java (in java.lang package) provides several important methods to create, control, and manage threads.

Commonly Used Thread Class Methods:

1)start():
Starts a new thread and calls the run() method internally.
You should never call run() directly; use start().

2)run():
Defines the task to be executed by the thread.
Must be overridden when extending Thread or implementing Runnable.

Top comments (0)