Thread Tutorial in java in detail with programs

You are here : Home / Core Java Tutorials

Threads basics in threads / Multithreading tutorial in java >

What is thread in java

Thread states/ Thread life cycle in java in detail with diagram, examples and scenarios

Difference between Process and Thread in java



Write your first thread in java >

Implementing Threads in java by implementing Runnable interface and extending Thread class - How to create your first thread in java/ Learn creating more than one thread (Multithreads) in java


Threads implement their own stack in java - demonstration using program/examples and diagram in threads / Multithreading tutorial

Differences between implementing Runnable interface and extending Thread class in threads / Multithreading tutorial in java

Thread behaviour is unpredictable in threads / Multithreading tutorial in java

When threads are not lightweight process in java, in fact they become heavy weight process


run() and Start() methods in threads / Multithreading tutorial in java >

What will happen if we don’t override run method of thread in java?

What will happen if we override start method of thread in java?

Difference between starting thread with run() and start() methods in java

Can we start Thread again in java?

Volatile keyword vs synchronized in threads / Multithreading tutorial in java>

Volatile keyword in java- difference between synchronized and volatile, 10 key points about volatile keyword, why volatile variables are not cached in memory in threads / Multithreading tutorial in java

Differences between synchronized and volatile keyword in detail in java


Race Condition in threads / Multithreading tutorial in java >

Race condition in multithreading and it's solution in java



Consumer Producer problem solution using different techniques in threads/Multithreading tutorial in java >
Solve Consumer Producer problem by using wait() and notify() methods in multithreading tutorial in java

solve Consumer Producer problem by using wait() and notify() methods, where consumer can consume only when production is over in java


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



BlockingQueue in threads / Multithreading tutorial in java >

Solve Consumer Producer problem by using BlockingQueue in multithreading in java


Custom implementation of LinkedBlockingQueue class which implements BlockingQueue interface in threads / Multithreading tutorial in java





DeadLock and its detection in threads / Multithreading tutorial in java >

Deadlock in multithreading - program/example to form DeadLock, solving DeadLock, measures to avoid Deadlock in java.


VisualVM - Thread dumps - Generating and analyzing Thread Dumps using VisualVM - step by step detail to setup VisualVM with screenshots in java


JSTACK - Thread dumps - Generating and analyzing Thread Dumps using JSATCK - step by step detail to setup JSTACK with screenshots in java


Reason why suspend() and resume() methods are deprecated and Deadlock prone in threads / Multithreading tutorial in java

destroy() method in java - usage, reason why destroy() method is deprecated and Deadlock prone in threads / Multithreading tutorial in java.




Important Thread methods (salient features, usage with programs/example) in threads / Multithreading tutorial in java>

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


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 in java.



Daemon threads - 12 salient features of Daemon Thread in java

2 alternate ways to stop thread, as stop() method is deprecated in java


Join() method - 10 salient features of join in java

Thread isAlive() method in threads / Multithreading tutorial in java

interrupt() method of thread in java


holdsLock(object) method to find whether current thread holds the lock on monitor of specified object in java.

Thread priorities - setPriority() and getPriority() methods in java

Using Suspend and resume method in threads in threads / Multithreading tutorial in java



Methods for Adding ShutdownHook and handling uncaught runtime exception in threads / Multithreading tutorial in java >

Threads addShutdownHook method in java

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



Differences between important thread methods in threads / Multithreading tutorial in java >

Difference between Process and Thread in java

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

Differences and similarities between yield() and sleep() in threads in java

Difference between notify() and notifyAll() methods, with program in threads / Multithreading tutorial in java

Difference between wait() and wait(long timeout) -What will be Thread states in java


Difference between object Lock and class Lock in threads / Multithreading tutorial in java

Difference between traditional synchronization and Condition interface in java

Difference between starting thread with run() and start() methods in java

Differences between implementing Runnable interface and extending Thread class in threads / Multithreading tutorial in java

Differences between synchronized and volatile keyword in detail in java




Object and class lock in threads / Multithreading tutorial in core java >

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 in java.


Acquiring lock on class, 2 Ways to acquire lock on class in java

Difference between object Lock and class Lock in threads / Multithreading tutorial in java




Thread Pool, Thread local, Busy Spin, ThreadGroup  in threads / Multithreading tutorial in java >

Implement own Thread pool in java

Implementing ThreadPool using custom LinkedBlockingQueue

ThreadLocal in multithreading in threads / Multithreading tutorial in java - methods and usage with program/example

Busy Spin - What is busy spin? Consumer Producer problem with busy spin and solution to busy spin in java.

ThreadGroup in java

Demonstrate ThreadGroup's important methods in DETAIL in java



Green threads in threads / Multithreading tutorial in java >

What are Green Threads in java

Difference between Green Threads and non-green/native threads in java





Situation based questions in threads / Multithreading tutorial in core java -

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 in java?


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 in java?


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 in java?


Suppose you have thread and it is in synchronized method and now can thread enter other synchronized method from that method in java?


Suppose you have thread and it is in static synchronized method and now can thread enter other static synchronized method from that method in java?


Suppose you have thread and it is in static synchronized method and now can thread enter other non static synchronized method from that method in java?


Suppose you have thread and it is in synchronized method and now can thread enter other static synchronized method from that method in java?


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 in java?


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 in java?




Guidelines to threadsafe code in core java >


More about Threads in threads / Multithreading tutorial in java >

Thread Starvation in java

Constructor in java cannot be synchronized in java


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



Top Thread Interviews questions in core java thread tutorial>

THREADS - Top 80 interview questions and answers (detailed explanation with programs/examples) Set-1 >  Q1- Q60 in java

THREADS - Top 80 interview questions and answers, important interview OUTPUT questions and answers, Set-2 > Q61- Q80





Summary -
In this core java tutorial we learned about threads/ Multithreading in detail with lots of programs and examples.


Having any doubt? or you liked the tutorial! Please comment in below section.
Please express your love by liking JavaMadeSoEasy.com (JMSE) on facebook, following on google+ or Twitter.


RELATED LINKS>

Thread Concurrency Tutorial in java

Collection framework Tutorial in java in detail with diagrams and programs

Exceptions Tutorial in java in detail with diagrams and programs



No comments:

Post a Comment