Java Multithreading

  1. Introduction
  2. Defining a Thread in java by extending Thread class.(7 special case)
  3. Defining a Thread in java using Runnable Interface
  4. Defining a Thread in java using Callable and collecting in FutureTask
  5. Naming of Thread, Getting and setting name of thread
  6. Thread priorities
  7. The methods to prevent Thread execution(Yield/Join/Sleep/Interrupt)
  8. Interrupt a sleeping,waiting thread.
  9. Thread Synchronization (synchronized method)
  10. Synchronized block
  11. Inter thread communication (wait/notify/notifyAll)
  12. What is Thread Safety in Java
  13. Deadlock
  14. Demon Threads
  15. Green Thread stop(), suspend() and resume()
  16. Thread life cycle in java
  17. Thread Group
  18. Lock Interface of java.util.concurrent package
  19. ReentrantLock Class
  20. Reentrant ReadWriteLock
  21. Executor Framework
  22. Thread pools (Executor Framework)
  23. Callable and Future
  24. Thread local
  25. Fork and Join Framework
  26. CountDownLatch
  27. CyclicBarrier
  28. Volatile in Java
  29. Atomic in Java. Examples of Atomic in Java
    1. AtomicBoolean
    2. AtomicInteger
    3. AtomicLong
    4. AtomicReference
    5. AtomicStampedReference
    6. AtomicIntegerArray
    7. AtomicLongArray
    8. AtomicReferenceArray
  30. Transient in Java
  31. Exchanger (Refer Jenkov)
  32. Semaphore (Refer Jenkov)

Referece :

Future Topics

  1. When to write a threadsafe code using vector?
  2. Transient, Volatile and Atomic Variables
  3. Concurrent Collections in java
  4. Stack size in Thread
  5. Producer Consumer Problem and Race Condition

Interview Questions :

  • What are the benefits of using Multithreading?
  • What is Thread in Java?
  • What are the two ways of implementing thread in Java?
  • What’s the difference between thread and process?
  • What’s the difference between class lock and object lock?
  • How many ways we can set a Thread name ?
  • What’s the difference between User thread and Daemon thread?
  • How can we create daemon threads? Example
  • What are the wait() and sleep() methods?
  • What’s the difference between notify() and notifyAll()?
  • Why wait(), notify(), and notifyAll() methods are present in Object class?
  • What is Runnable and Callable Interface? Write the difference between them.
  • What is the start() and run() method of Thread class?
  • Explain thread pool?
  • What’s the purpose of the join() method?
  • What do you mean by garbage collection?
  • Explain the meaning of the deadlock and when it can occur?
  • Explain volatile variables in Java?
  • How do threads communicate with each other?
  • Can two threads execute two methods (static and non-static concurrently)?
  • What is the purpose of the finalize() method?
  • What is the synchronization process? Why use it?
  • What is synchronized method and synchronized block? Which one should be preferred?
  • What is thread starvation?
  • What is Livelock? What happens when it occurs?
  • What is BlockingQueue?
  • Can you start a thread twice?
  • Explain context switching.
  • What is CyclicBarrier and CountDownLatch?
  • What do you mean by inter-thread communication?
  • What is Thread Scheduler and Time Slicing?
  • What is a shutdown hook?
  • What is busy spinning?
  • What is ConcurrentHashMap and Hashtable? In java, why is ConcurrentHashMap considered faster than Hashtable?
  • Explain thread priority.
  • What do you mean by the ThreadLocal variable in Java?
  • What is semaphore?
  • Explain Thread Group. Why should we not use it?
  • What is the ExecutorService interface?
  • What will happen if we don’t override the thread class run() method?
  • What is the lock interface? Why is it better to use a lock interface rather than a synchronized block.?
  • Is it possible to call the run() method directly to start a new thread?
  • Is it possible that each thread can have its stack in multithreaded programming?

Reference :

Study Material from YoutubePlayList