Interview Question

Difference between thread and process?

Threads share memory; processes isolate memory and support CPU parallelism.

💡 Concept ✅ Quick Revision 🐍 Python

Answer

Threads share a process and memory; processes have separate memory spaces. • Threads have lower communication overhead but need synchronization around shared state. • Processes provide stronger isolation and can use multiple cores for Python bytecode. • The correct choice depends on I/O, CPU work, state sharing, and deployment cost.

💡 Simple Example

from threading import Thread from multiprocessing import Process print(Thread.__name__, Process.__name__)

Output

Thread Process

⚡ Quick Revision

Threads share memory; processes isolate memory and support CPU parallelism.