Unit 2 home
Class 21 of 60 Part I · Orange UI24PC320CS
Placeholder · not written yet

Two things at once — what a thread is, and why your app needs them

Your food-delivery app shows a live map and updates the order status at the same time. Neither waits for the other. That is not magic — it is two threads, and this session is where you make your first one.

Class 21 Part I · C21–C24 Threads begin

This session has not been authored yet

You have reached a real page, but an empty one. The deck for Class 21 is planned in full in the course knowledge document and is queued for authoring — nothing on this page is finished teaching content.

The roster underneath is the actual plan for this session, so you can see exactly what will land here.

What this class will cover

  1. Part-I openerThe orange arc across Classes 21–24, ending at deadlock and the Unit-2 close.
  2. Process vs threadWhat the operating system hands out, and what your program divides up inside it.
  3. Why an app needs more than oneThe live map and the order status, both moving, neither blocking the other.
  4. Creating a thread · extends ThreadThe first of the two ways, with a real running example.
  5. Creating a thread · implements RunnableThe second way, and why it is usually the better one.
  6. Which should you use?The honest comparison — inheritance budget, reusability, and what interviewers expect you to say.
  7. Worked exampleTwo threads running side by side, with genuine interleaved output that differs between runs.
  8. Activities + close cardHands-on thread creation, then the Class-21 close and the runway into the lifecycle.

Fair warning

From here on, running the same program twice can give you two different answers — and that is correct behaviour, not a bug. Getting comfortable with that is most of what Part I teaches.