#90 Thread States in Java

  Рет қаралды 47,910

Telusko

Telusko

Күн бұрын

Check out our courses:
Enterprise Java Spring Microservices: go.telusko.com...
Coupon: TELUSKO10 (10% Discount)
Master Java Spring Development : go.telusko.com...
Coupon: TELUSKO20 (20% Discount)
For More Queries WhatsApp or Call on : +919008963671
Udemy Courses:
Spring: go.telusko.com...
Java:- go.telusko.com...
Java Spring:- go.telusko.com...
Java For Programmers:- go.telusko.com...
Python : go.telusko.com...
Git : go.telusko.com...
Docker : go.telusko.com...
website : courses.telusk...
In this lecture we will learn:
- Different states of a thread
- Method used for each state of a thread
- Flow chart diagram of a thread cycle
- Difference between Runnable and Running state
#1
- Every time you create a new thread that goes into a new state.
- When you start a thread, it goes into the Runnable state.
When the thread is executing and then it is waiting for the schedular, it is in a runnable state.
- When the thread is actually running on a CPU, it is in a Running state.
The thread executes with the help of the run() method in a running state.
A thread goes in the running state only when it gets informed by the schedular to get executed.
- The thread can be held with the help of the sleep() or wait() method, then will go into the waiting state.
- With the use of notify() method, the thread goes to the Runnable state from the waiting state.
- You can stop the execution of a thread by using a stop() method, and then it will go into the Dead State.
When the work of a thread gets over, then it will go into the dead state automatically.
#2
start() notify()
New -----------} Runnable {------------
| | |
| |run() |
| | |
|Runnning ----------}Waiting
| | sleep() or wait()
| |
| |__stop()____Dead
|_______________|
stop()
Github repo : github.com/nav...
Java:- bit.ly/JavaUde...
Spring:- bit.ly/SpringU...
More Learning :
Java :- bit.ly/3x6rr0N
Python :- bit.ly/3GRc7JX
Django :- bit.ly/3MmoJK6
JavaScript :- bit.ly/3tiAlHo
Node JS :- bit.ly/3GT4liq
Rest Api :-bit.ly/3MjhZwt
Servlet :- bit.ly/3Q7eA7k
Spring Framework :- bit.ly/3xi7buh
Design Patterns in Java :- bit.ly/3MocXiq
Docker :- bit.ly/3xjWzLA
Blockchain Tutorial :- bit.ly/3NSbOkc
Corda Tutorial:- bit.ly/3thbUKa
Hyperledger Fabric :- bit.ly/38RZCRB
NoSQL Tutorial :- bit.ly/3aJpRuc
Mysql Tutorial :- bit.ly/3thpr4L
Data Structures using Java :- bit.ly/3MuJa7S
Git Tutorial :- bit.ly/3NXyCPu
Donation:
PayPal Id : navinreddy20
www.telusko.com

Пікірлер: 9
@aileenchan3741
@aileenchan3741 Жыл бұрын
This channel is the best! Thank you so much for sharing your knowledge. Today I learned about threads, multithreading, thread states... phew! : )
@udayy4448
@udayy4448 8 ай бұрын
This was really helpful. Thanks very much Navin!
@dragnar4743
@dragnar4743 5 ай бұрын
So, runnable state is basically saying to the scheduler that the thread is ready for execution. That makes sense, why after sleep(), the thread goes to runnable instead of running. Because, after sleep() the thread is again gets ready for the schedular to pick it up and put it in running state.
@animefreak6724
@animefreak6724 5 ай бұрын
When a thread calls the sleep() method, it enters a "timed waiting" state. This means the thread voluntarily gives up the CPU for at least the specified amount of time. After that time has passed, the thread moves back to the "runnable" state, indicating that it is ready to run again but is waiting for the scheduler to allocate CPU time. The reason threads don't immediately go from "runnable" to "running" after sleep() is because the scheduler still needs to determine when to allocate CPU time to that thread based on its priority, the presence of higher-priority threads, and other scheduling policies.
@dragnar4743
@dragnar4743 5 ай бұрын
@@animefreak6724 yup, exactly
@akashchoudhary9161
@akashchoudhary9161 Жыл бұрын
sir you escaped the multithreading inter thread comunication concept... any reason?
@96fan322
@96fan322 Жыл бұрын
I want to become a app developer, Present I know Java basics Can you tell what to learn
@svedits7567
@svedits7567 10 ай бұрын
basics are not enough for android development. You have to learn the features of Android Studio. How views, Layouts etc etc work. I'd recommend you take an android development course in java or kotlin
@avisekdas-gmail5055
@avisekdas-gmail5055 Жыл бұрын
Hi Navin, Can you please provide us a tutorial for executor frame work, Threadpool, Issues with Furure object and how it handled by completable future in Java 8.
#91 Collection API in Java
4:49
Telusko
Рет қаралды 92 М.
Exception Handling in Java | ArithmeticException
19:44
Learn Coding
Рет қаралды 838 М.
How Strong is Tin Foil? 💪
00:26
Preston
Рет қаралды 63 МЛН
小丑在游泳池做什么#short #angel #clown
00:13
Super Beauty team
Рет қаралды 37 МЛН
Reliability and Validity in Research: Parallel Forms Reliability
5:16
#89 Race Condition in Java
12:30
Telusko
Рет қаралды 65 М.
Multithreading in Java Explained in 10 Minutes
10:01
Coding with John
Рет қаралды 920 М.
THREAD LIFE CYCLE - JAVA PROGRAMMING
9:21
Sundeep Saradhi Kanthety
Рет қаралды 171 М.
#86 Multiple Threads in Java
11:30
Telusko
Рет қаралды 121 М.
Learn Any Programming Language In 3 Hours!
22:37
Code With Huw
Рет қаралды 373 М.
What is the difference between Task and Thread in C#?
9:24
C# interview questions
Рет қаралды 17 М.
#92 ArrayList in Java
11:54
Telusko
Рет қаралды 107 М.