Skip to content

Latest commit

 

History

History
54 lines (49 loc) · 2.66 KB

File metadata and controls

54 lines (49 loc) · 2.66 KB

Multithreading

  • One of most asked topic and most confusing one too. So, here is the complete list of questions and answers to learn and understand multithreading.

Questions:

  1. What is the difference between Process and Thread?
  2. What is difference between user Thread and daemon Thread?
  3. How can we create a Thread in Java?
  4. What are different states in lifecycle of Thread?
  5. Can we call run() method of a Thread class?
  6. How can we pause the execution of a Thread for specific time?
  7. What do you understand about Thread Priority?
  8. What is context-switching in multi-threading?
  9. How can we make sure main() is the last thread to finish in Java Program?
  10. How does thread communicate with each other?
  11. Why thread communication methods wait(), notify() and notifyAll() are in Object class?
  12. Why wait(), notify() and notifyAll() methods have to be called from synchronized method or block?
  13. Why Thread sleep() and yield() methods are static?
  14. How can we achieve thread safety in Java?
  15. What is volatile keyword in Java
  16. Which is more preferred - Synchronized method or Synchronized block?
  17. How to create daemon thread in Java?
  18. What is Thread Group? Why it’s advised not to use it?
  19. What is Deadlock? How to analyze and avoid deadlock situation?
  20. What is Java Timer Class? How to schedule a task to run after specific interval?
  21. What is Thread Pool? How can we create Thread Pool in Java?
  22. What will happen if we don’t override Thread class run() method?

Some More Questions To Explore:

  1. What is the need for threads in Java?
  2. How do you create a thread?
  3. How do you create a thread by extending thread class?
  4. How do you create a thread by implementing runnable interface?
  5. How do you run a thread in Java?
  6. What are the different states of a thread?
  7. What is priority of a thread? How do you change the priority of a thread?
  8. What is executorservice?
  9. Can you give an example for executorservice?
  10. Explain different ways of creating executor services .
  11. How do you check whether an executionservice task executed successfully?
  12. What is callable? How do you execute a callable from executionservice?
  13. What is synchronization of threads?
  14. Can you give an example of a synchronized block?
  15. Can a static method be synchronized?
  16. What is the use of join method in threads?
  17. Describe a few other important methods in threads?
  18. What is a deadlock?
  19. What are the important methods in Java for inter-thread communication?
  20. What is the use of wait method?
  21. What is the use of notify method?
  22. What is the use of notifyall method?
  23. Can you write a synchronized program with wait and notify methods?