What resources are shared between threads?

Recently, I have been asked a question in an interview what’s the difference between a process and a thread. Really, I did not know the answer. I thought for a minute and gave a very weird answer.

Threads share the same memory, processes do not. After answering this, the interviewer gave me an evil smile and fired the following questions at me:

Q. Do you know the segments in which a program gets divided?

My answer: yep (thought it was an easy one) Stack, Data, Code, Heap

Q. So, tell me: which segments do threads share?

I could not answer this and ended up in saying all of them.

Please, can anybody present the correct and impressive answers for the difference between a process and a thread?

13 Answers
13

Leave a Comment