Tech Master Tutorials
Email Facebook Google LinkedIn Pinterest Twitter
Home Java Java 8 Java Interview Questions Java Programming

Why Threads ?



And a thread is a light weight process. Threads are light weight because threads share the same resources – same data (program text, heap memory and files). Each thread has its own memory stack.

Benefits of using Threads

  • Light weight : As threads share same resources
  • Performance : Threads can execute in parallel on multiple processors
  • Thread Management vs Process Management: Sharing the same memory space and data among the threads makes it easier to share resources and things like context switching



Overheads:
  • Requires synchronization among threads otherwise will lead to inconsistency of the system