- Java Thread and Multithreading Tutorial
- Java Thread Example
- Java Thread Sleep
- Java Thread Join
- Java Thread States
- Java Thread wait, notify and notifyAll
- Java Thread Safety and Java Synchronization
- Java Exception in thread main
- Thread Safety in Singleton Class
- Java Daemon Thread
- Java Thread Local
- Java Thread Dump
- How to Analyze Deadlock and avoid it in Java
- Java Timer Thread
- Java Producer Consumer Problem
- Java Thread Pool
- Java Callable Future
- Java FutureTask Example
Java Thread and Multithreading Tutorial
There are two types of threads in an application – user thread
and daemon thread
. When we start an application, main is the first user thread created and we can create multiple user threads as well as daemon threads. When all the user threads are executed, JVM terminates the program.
We can set different priorities to different Threads but it doesn’t guarantee that higher priority thread will execute first than lower priority thread. Thread scheduler is the part of Operating System implementation and when a Thread is started, it’s execution is controlled by Thread Scheduler and JVM doesn’t have any control on it’s execution.