You are on page 1of 2

Thread basics >

What is thread in java


Thread states/ Thread life cycle in java
Difference between Process and Thread in java
Implementing Threads in java by implementing Runnable interface and extending Thread class
Threads implement their own stack - demonstration using program and diagram
Differences between implementing Runnable interface and extending Thread class
Thread behaviour is unpredictable
When threads are not lightweight process in java, in fact they become heavy weight process

run() and Start() methods >

What will happen if we dont override run method of thread?


What will happen if we override start method of thread?
Difference between starting thread with run() and start() methods in java
Can we start Thread again?

Volatile keyword vs synchronized>

Volatile keyword in java- difference between synchronized and volatile, 10 key points about volatile keyword, why volatile variables are
not cached in memory
Differences between synchronized and volatile keyword in detail

Race Condition >

Race condition in multithreading and it's solution

Consumer Producer problem solution using different techniques >


Solve Consumer Producer problem by using wait() and notify() methods in multithreading
solve Consumer Producer problem by using wait() and notify() methods, where consumer can consume only when production is over
How to solve Consumer Producer problem without using wait() and notify() methods, where consumer can consume only when production is
over.

BlockingQueue >

Solve Consumer Producer problem by using BlockingQueue in multithreading


Custom implementation of LinkedBlockingQueue class which implements BlockingQueue interface
Producer Consumer pattern using Custom implementation of BlockingQueue interface

DeadLock and its detection >

Deadlock in multithreading - program to form DeadLock, solving DeadLock, measures to avoid Deadlock.
VisualVM - Thread dumps - Generating and analyzing Thread Dumps using VisualVM - step by step detail to setup VisualVM with screenshots
JSTACK - Thread dumps - Generating and analyzing Thread Dumps using JSATCK - step by step detail to setup JSTACK with screenshots
Reason why suspend() and resume() methods are deprecated and Deadlock prone
destroy() method in java - usage, reason why destroy() method is deprecated and Deadlock prone.

Important Thread methods (salient features, usage with programs)>

Sleep() method in threads - 10 key features with programs


Wait() and notify() methods- Definition, 8 key features, solving consumer producer problem with & without these methods and consequences
of not using wait() and notify() methods.
Yield() method in threads - 8 key features with programs
Daemon threads - 12 salient features of Daemon Thread
2 alternate ways to stop thread, as stop() method is deprecated
Join() method - 10 salient features of join
Thread isAlive() method
interrupt() method of thread in java
holdsLock(object) method to find whether current thread holds the lock on monitor of specified object.
Thread priorities - setPriority() and getPriority() methods
Using Suspend and resume method in threads

Methods for Adding ShutdownHook and handling uncaught runtime exception >

Threads addShutdownHook method in java


Handling uncaught runtime exception generated in run method using - setDefaultUncaughtExceptionHandler method

Differences between important thread methods >

Difference between wait() and sleep() method in threads


Differences and similarities between yield() and sleep() in threads
Difference between notify() and notifyAll() methods, with program
Difference between wait() and wait(long timeout) -What will be Thread states

Object and class lock >

Acquiring object lock - synchronization blocks and methods- multiple threads may exist on same object but only one thread of that
object can enter synchronized block/method at a time.
Acquiring lock on class, 2 Ways to acquire lock on class
Difference between object Lock and class Lock
Why wait(), notify() and notifyAll() are in Object class and not in Thread class

Thread Pool, Thread local, Busy Spin, ThreadGroup >


Implement Thread pool in java
Implementing ThreadPool using custom LinkedBlockingQueue
ThreadLocal in multithreading in java - methods and usage with program
Busy Spin - What is busy spin? Consumer Producer problem with busy spin and solution to busy spin.
ThreadGroup in java
Demonstrate ThreadGroup's important methods in DETAIL

Green threads in java >


What are Green Threads in java

Situation based questions Suppose you have 2 threads (Thread-1 and Thread-2) on same object. Thread-1 is in synchronized method1(), can Thread-2 enter
synchronized method2() at same time?
Suppose you have 2 threads (Thread-1 and Thread-2) on same object. Thread-1 is in static synchronized method1(), can Thread-2 enter
static synchronized method2() at same time?
Suppose you have 2 threads (Thread-1 and Thread-2) on same object. Thread-1 is in synchronized method1(), can Thread-2 enter static
synchronized method2() at same time?
Suppose you have thread and it is in synchronized method and now can thread enter other synchronized method from that method?

Suppose you have thread and it is in static synchronized method and now can thread enter other static synchronized method from that
method?
Suppose you have thread and it is in static synchronized method and now can thread enter other non static synchronized method from that
method?
Suppose you have thread and it is in synchronized method and now can thread enter other static synchronized method from that method?
Suppose you have 2 threads (Thread-1 on object1 and Thread-2 on object2). Thread-1 is in synchronized method1(), can Thread-2 enter
synchronized method2() at same time?
Suppose you have 2 threads (Thread-1 on object1 and Thread-2 on object2). Thread-1 is in static synchronized method1(), can Thread-2
enter static synchronized method2() at same time?

Guidelines to threadsafe code >

Guidelines to thread safe code, most important point we must take care of in multithreading programs

More about Threads >

Thread Starvation
Constructor in java cannot be synchronized
The awakened threads will not be able to proceed until the current thread relinquishes the lock on this object

ThreadDeath error - calling stop method on thread throws ThreadDeath error in java

Top Thread Interviews questions>

Thread Concurrency Tutorial


Executor framework >

Executor and ExecutorService framework in java

Atomic operations >

Atomic operations in java


AtomicInteger in java
Implementation of custom/own AtomicInteger in java
AtomicLong in java
Implementation of custom/own AtomicLong in java
AtomicBoolean in java

Semaphore >

Semaphore in java
Implementation of custom/own Semaphore in java
Semaphore used for implementing Producer Consumer pattern
Custom Semaphore used for implementing Producer Consumer pattern

Lock and Reentrant Locks >

Locks and ReEntrantLocks in java


Implementation of custom/own Lock and ReEntrantLock in java
ReentrantLock class provides implementation of Locks newCondition() method - description and solving producer consumer program using this
method
What are applications of ReEntrantLock in java

ReadWriteLock and ReentrantReadWriteLock >


ReadWriteLock and ReentrantReadWriteLock in java
Implementation of custom/own ReadWriteLock and ReentrantReadWriteLock in java

CountDownLatch >

CountDownLatch in java
Implementation of custom/own CountDownLatch in java

CyclicBarrier >
CyclicBarrier in java
Implementation of custom/own CyclicBarrier in java

Phaser >

Phaser in java
How to use parent and child Phaser in java

Exchanger >
Exchanger in java

Future and Callable >


What is java.util.concurrent.Future and Callable in thread concurrency in java

Fork/Join framework >

Fork/Join Framework - Parallel programming in java

BlockingQueue and LinkedBlockingQueue >


Solve Consumer Producer problem by using BlockingQueue in multithreading
Custom implementation of LinkedBlockingQueue class which implements BlockingQueue interface
Producer Consumer pattern using Custom implementation of BlockingQueue interface

Implementing ThreadPool using custom LinkedBlockingQueue

Important Similarity and Differences >

Differences between execute() and submit() method of executor framework


Difference between synchronized and ReentrantLock
Similarity and Difference between CyclicBarrier and CountDownLatch in Java
differences between java.util.concurrent.Callable and java.lang.Runnable

You might also like