Explain the difference between a process and a thread. When would you use multi-threading?
Define both concepts clearly. Explain that a process is an independent execution unit with its own memory space, while a thread is a lightweight execution path within a process sharing the same memory. Highlight resource costs, context-switching latency, and scenarios like concurrency in web servers or CPU-bound background processing.
"A process is an instance of a running application that has its own isolated memory address space. A thread is the smallest execution unit within a process, sharing the parent process's memory, files, and resources. I would use multi-threading to achieve concurrency when executing independent tasks that share data, such as handling concurrent HTTP requests in a web server or processing image rendering pieces in parallel, to maximize CPU utilization without the heavy overhead of context-switching between separate processes."