Loading
Java Thread-interview

Q1. Difference between process and thread.
  • Process: Heavy, has its own memory space.
  • Thread: Lightweight, shares memory of the process.





Q2. Difference between user thread and daemon thread.
  • User Thread: Runs until completion.
  • Daemon Thread: Runs in background (e.g., Garbage Collector) and terminates when all user threads finish.







Q3.  How can we create a thread in Java?
  • Extending Thread class and overriding run() method.
  • Implementing Runnable interface and passing it to a Thread object.






Q4. Difference between join() and yield().
  • join() One thread waits until another finishes.
  • yield() Suggests the scheduler to pause and give other threads a chance.






Q5. What is thread priority and its default value?
Each thread has a priority (1 to 10). Default = 5 (NORM_PRIORITY). Higher priority threads may execute earlier, but scheduling is JVM + OS dependent.