Question #42: Do threads need different stack?
- Yes, they have different execution tracks, hence they need different stacks.
- Sometimes they need.
- No, they have common code segment, hence they don’t need different stacks.
- None of the above.
Solution:
Stack grows and shrinks as and when threads take different paths. And, multiple threads in same or different processes can take different execution paths, hence a dedicated stack is needed for all of the threads to execute. Therefore, the correct answer is option 1.