Explain the difference between a process and a thread.
Model answer
A process is an independent program with its own memory space. A thread is a lightweight unit of execution within a process that shares the process's memory. Multiple threads within a process can run concurrently and share data, but context switching between threads is faster than between processes. In Java, threads are managed via the Thread class or Runnable interface; in Python, the GIL limits true CPU parallelism for threads.