Loading
Java Multitasking-interview

Q1. What is multitasking in Java? Explain its types.

Multitasking in Java is the ability to perform multiple tasks simultaneously.

  • Process-based multitasking Executes multiple programs at the same time (e.g., running Chrome, MS Word, and Eclipse).
  • Thread-based multitasking Executes multiple threads inside a single program (e.g., a chat app sending and receiving messages simultaneously).





Q2. Differentiate between process-based multitasking and thread-based multitasking.

Aspect

Process-based Multitasking

Thread-based Multitasking

Execution Unit

Process

Thread

Memory

Each process has its own memory

Threads share memory of the process

Cost

Heavy (resource-intensive)

Lightweight

Communication

Slow (inter-process)

Fast (inter-thread)

Example

Running multiple applications

Multiple threads in one Java program







Q3. Why is thread-based multitasking more efficient than process-based multitasking?
  • Threads share the same memory space less memory required.
  • Context switching between threads is faster than between processes.
  • Communication between threads is easier and faster.






Q4. Give real-world examples of multitasking in Java applications.
  • Web servers – Handling multiple client requests simultaneously.
  • Multimedia players – Playing audio, video, and showing subtitles at once.
  • Chat applications – Sending and receiving messages at the same time.
  • Banking systems – Processing transactions while sending notifications.