Multithreading in Java

Table of Contents

Thread Life Cycle in Java

Thread-Lifecycle-States

Java Thread Dump or Analyze Deadlock

  • Java Mission Control -> Thread Dump

Java Multithreading Interview Questions

  1. What is the difference between Process and Thread?

  2. What are the benefits of multi-threaded programming?

  3. What is difference between user Thread and daemon Thread?

  4. How can we create a Thread in Java?

  5. What are different states in lifecycle of Thread?

  6. Can we call run() method of a Thread class?

  7. How can we pause the execution of a Thread for specific time?

  8. What do you understand about Thread Priority?

  9. What is Thread Scheduler and Time Slicing?

  10. What is context-switching in multi-threading?

  11. How can we make sure main() is the last thread to finish in Java Program?

  12. How does thread communicate with each other?

  13. Why thread communication methods wait(), notify() and notifyAll() are in Object class?

  14. Why wait(), notify() and notifyAll() methods have to be called from synchronized method or block?

  15. Why Thread sleep() and yield() methods are static?

  16. How can we achieve thread safety in Java?

  17. What is volatile keyword in Java

  18. Which is more preferred – Synchronized method or Synchronized block?

  19. How to create daemon thread in Java?

  20. What is ThreadLocal?

  21. What is Thread Group? Why it’s advised not to use it?

  22. What is Java Thread Dump, How can we get Java Thread dump of a Program?

  23. What is Deadlock? How to analyze and avoid deadlock situation?

  24. What is Java Timer Class? How to schedule a task to run after specific interval?

  25. What is Thread Pool? How can we create Thread Pool in Java?

  26. What will happen if we don’t override Thread class run() method?

Java Concurrency Interview Questions

  1. What is atomic operation? What are atomic classes in Java Concurrency API?

  2. What is Lock interface in Java Concurrency API? What are it’s benefits over synchronization?

  3. What is Executors Framework?

  4. What is BlockingQueue? How can we implement Producer-Consumer problem using Blocking Queue?

  5. What is Callable and Future?

  6. What is FutureTask class?

  7. What are Concurrent Collection Classes?

  8. What is Executors Class?

  9. What are some of the improvements in Concurrency API in Java 8?

Tips

References