KASA VLAB · Advanced Python ProgrammingConcurrency with Python · Golden Cell
3 Interactive Tabs
CONCURRENCY WITH PYTHON

Coordinate Tasks. Run Threads. Control Execution.

Three progressive missions using the KASA Python Runtime.

Visualize Concurrency

Concurrency manages multiple tasks whose lifetimes overlap. Drag each scenario to the execution model that best describes it.

Scenario Cards

A → B → C, finish one by one Download while UI remains responsive Two CPU workers execute chunks simultaneously
Drag all three cards.

Execution Models

① Sequential
② Concurrent / Interleaving
③ Parallel
Python threads are commonly useful for I/O-bound work: while one thread waits, another can make progress.

Thread Foundation

Thread(target, args) → start() → join(). Complete the TODOs and run the editable code.

Ready.

Animated Thread Timeline

Main
Thread-A
Thread-B

Run the simulation: Main starts workers → A/B overlap → Main waits at join() → complete.

start() begins thread execution. join() waits until that thread finishes.

Challenge · Custom Thread

Extend threading.Thread. The SYSTEM CALL is fixed—make your class fit the required interface without changing the caller.

Target: Worker-A -> load Worker-A -> process Worker-A -> save SYSTEM: completed

System Contract

1 · Extend
WorkerThread(threading.Thread)
2 · Initialize
super().__init__() + store worker_name/jobs
3 · Override run()
Put work executed by start() here
4 · Preserve Caller
Do not modify the supplied SYSTEM CALL

Implement the class, then validate.

🔒 Instructor Solution

Secure solution: PBKDF2-SHA256 (150,000) + AES-GCM-256.