Q160: Threads over processes?

Question160: Is there any benefit using threads over processes?

Options:

  1. No, processes are better as they provide better isolation.
  2. Yes, threads are beneficial as they are light weight to spawn.
  3. Yes, threads share code segment thereby saving memory.
  4. Both B and C depending on use case.

Solution: The correct answer is the last one. Threads are kind of light weight processes, they also share code segment with each other within the same process. Threads are useful for lightweight tasks whereas processes are useful for heavy weight tasks.