Multithreading

  1. MultiThreading vs MultiProcessing vs MultiProgramming vs MultiTasking?
  2. Life cycle of a Thread
  3. Extends vs Runnable
  4. yield() vs sleep() vs join() ?
  5. wait() vs sleep() ?
  6. why is join() method used?
  7. Can we Override start() method in Thread?
  8. Can we Override run() method?
  9. Can we start the thread twice?
  10. What is IllegalThreadStateException?
  11. What happens if run() method is called without start()?
  12. Why do we use ThreadPool?
  13. What is Race Condition?
  14. What is Synchronisation?Types of Synchronisation?
  15. Object Level Locking vs Class Level Locking?
  16. If there is 2 synchronised methods m1 and m2 in a class, can 2 different threads t1 and t2 call different methods(m1,m2) respectively on same object of class c at same time ?
    Answer — No. Only 1 Thread can hold the lock on a object of a class.However the other non synchronised methods can be called on same object.
  17. If a class has a synchronised method and non synchronised method, can multiple threads execute non synchronised methods?
    Answer: yes. If a class has a synchronised method and non synchronised method , multiple threads can access non synchronised methods.
  18. Can 2 threads call 2 different static synchronised methods of same class?
    Answer : The static synchronised methods of same class always block each other as 1 lock per class exists. So no 2 static synchronised methods can execute at the same time.
  19. Does static synchronised methods block a non synchronised methods?
    Answer: No. The thread executing static synchronised method holds a lock on the class and the executing the non static synchronised method holds lock on the object on which the method has been called, these 2 locks are different and these threads dont block eachother.
  20. Can Constructors be synchronised?
  21. What is DeadLock?
  22. What is Inter thread communication?Explain wait(),notify() and notifyall()?
  23. What is IllegalMonitorStateException?
  24. Which class does wait(),notify() and notifyall() method belong?
  25. Explain few Thread class methods?is Sleep() a method in Thread class or Object class?
  26. Producer Consumer Problem in Java?
  27. Volatile vs Synchronised?
  28. What are Atomic variables?

Author: Susheel kumar

Leave a Reply

Your email address will not be published. Required fields are marked *