What is the difference between a process and a thread?
A fundamental OS question comparing the characteristics, memory usage, and overhead of processes versus threads.
Why Interviewers Ask This
Understanding the distinction is vital for performance optimization and concurrency design. Interviewers check if you know when to use processes for isolation and threads for efficiency within a single application context.
How to Answer This Question
Start by defining both terms clearly. Highlight differences in memory space, creation overhead, and communication mechanisms. Emphasize that threads share memory while processes have separate address spaces. Mention context switching costs and how they impact system performance.
Key Points to Cover
- Memory space separation
- Creation and context switch overhead
- Communication mechanisms
- Isolation benefits
Sample Answer
A process is an independent program execution with its own memory space, while a thread is a lightweight unit of execution within a process. Threads share the same memory and resources, making communication faster but requiring synchronization. Processes are heavier due to separate memory allocation, offering better isolation and stability against crashes.
Common Mistakes to Avoid
- Claiming threads cannot crash the whole process
- Ignoring the sharing of global variables
- Overlooking security implications of shared memory
Practice This Question with AI
Answer this question orally or via text and get instant AI-powered feedback on your response quality, structure, and delivery.
Related Interview Questions
Explain company process?
Easy
TCSDo you know Java? What are some of its key features?
Easy
TCSWhat is Object-Oriented Programming in Java?
Medium
GoogleHow does exception handling work in Java and what is the difference between throw and throws?
Medium
TCSWhat is ER model in the DBMS?
Medium
FlipkartWhat is the difference between authentication and authorization?
Easy
Flipkart