# Multithreading in Java Multithreading is a Java feature that allows concurrent execution of two or more parts of a program for maximum utilization of CPU. Each part of such program is called a thread. So, threads are light-weight processes within a process. # Threads can be created by using two mechanisms : 1. Extending the Thread class 2. Implementing the Runnable InterfaceA thread can be in one of the five states. According to sun, there is only 4 states in thread life cycle in java new, runnable, non-runnable and terminated. There is no running state.But for better understanding the threads, we are explaining it in the 5 states.# The life cycle of the thread in java is controlled by JVM. The java thread states are as follows: 1. New : The thread is in new state if you create an instance of Thread class but before the invocation of start() method. 2. Runnable : The thread is in runnable state after invocation of start() method, but the thread scheduler has not selected it to be the running thread. 3. Running : The thread is in running state if the thread scheduler has selected it. 4. Non-Runnable (Blocked) : This is the state when the thread is still alive, but is currently not eligible to run. 5. Terminated : A thread is in terminated or dead state when its run() method exits. - Study24x7
Social learning Network
study24x7

Default error msg

Login

New to Study24x7 ? Join Now
Already have an account? Login
37 followers study24x7 05 Feb 2019 06:13 PM study24x7 study24x7

# Multithreading in Java Multithreading is a Java feature that allows concurrent execution of two or more parts of a program for maximum utilization of CPU. Each part of such program is called a thread. So, threads are light-weight processes within a process.
# Threads...

See more

# Multithreading in Java
			
Multithreading is a Java...
study24x7
Write a comment
Related Questions
500+   more Questions to answer
Most Related Articles