Exception Handling · Introduction to Java Programming

Single Tasking and Multitasking

Watch lectures

Single Tasking and Multitasking

1. Definitions (beginner)

Single-tasking = one job at a time (old phones: call OR sms!). Multitasking = many together (modern: music + map + chat!). Two kinds: process-based (apps!) + thread-based (inside app!).

2. Table (exam!)

Single Multitasking (process) Multitasking (thread)
Jobs 1 many apps many threads (one app!)
Memory one separate (safe, heavy!) shared Heap (fast, careful!)
Example DOS Chrome + VS Code music + download threads!
Switch cost — high (OS) low (JVM!)

3. Code Taste (feel the difference!)

// SINGLE (sequential: 6 sec!)
download(); // 3 sec
playMusic(); // 3 sec (waits!)
// MULTI (threads: ~3 sec!)
new Thread(() -> download()).start();
new Thread(() -> playMusic()).start(); // together!

4. Why Threads Win (viva!)

Shared memory (no copy!), cheap switch (same process!), JVM-managed. Risk: shared data races (need synchronized — later!).

5. Exam Points

  • Define + table + example — 5 marks, very frequent.
  • Process vs thread multitasking — 3-5 marks, frequent.
Budget AppAndroid App

Pocketly on Android

Log daily food, travel, and hostel expenses instantly. Set monthly spending limits and see where your money goes without complex spreadsheets.

← All Introduction to Java Programming modules