Navigate Select ESC Close

#86 Multiple Threads in Java

2023-01-19 Science & Technology
254.9k
3.9k
59
Telusko
Telusko
2.8m subscribers

Unlock all features

FREE: Get instant access to 10 AI summaries, chats, or transcripts per day.

Description

Check out our courses: Java Spring Boot AI Live Course: https://go.telusko.com/JavaSpringBootAI Coupon: TELUSKO20 (20% Discount) AI Powered DevOps with AWS - Live Course :- https://go.telusko.com/AIDevOps-AWS Coupon: TELUSKO20 (20% Discount) Master Java Spring Development : https://go.telusko.com/masterjava Coupon: TELUSKO20 (20% Discount) For More Queries WhatsApp or Call on : +919008963671 website : https://courses.telusko.com/ Udemy Courses: Spring: https://go.telusko.com/udemyteluskospring Java:- https://go.telusko.com/udemyteluskojava Java Spring:- https://go.telusko.com/Udemyjavaspring Java For Programmers:- https://go.telusko.com/javaProgrammers Python : https://go.telusko.com/udemyteluskopython Git : https://go.telusko.com/udemyteluskogit Docker : https://go.telusko.com/udemyteluskodocker Instagram : https://www.instagram.com/navinreddyofficial/ Linkedin : https://in.linkedin.com/in/navinreddy20 TELUSKO Android App : https://go.telusko.com/TELUSKOAPP TELUSKO IOS App : https://apple.co/3SsgmU2 Discord : https://discord.gg/D8hWe9BqfF In this lecture we will learn: - Multiple Threads in Java - How to create a thread? - How we can do parallel programming? - start() and run() methods in multithreading - Time-sharing between multiple threads #1 When you build an application, we use certain frameworks and behind the scene, these frameworks will create threads. - Every statement runs in a sequence in the main method. - If you want to execute two behaviours to execute at the same time, then we can use threads. - We can not execute normal objects in multiple threads or normal objects can not be executed simultaneously. #2 - Java provides a Thread class to achieve thread programming. The thread class provides constructors and methods to create and perform operations on a thread. - A thread can be created by extending the thread class. The thread class can be extended through the Thread keyword. - By using the Thread keyword with class, it will not create a new thread. #3 - We have to use the start() method in the main to start the execution of a new thread. - start() is a method that is present inside the thread class. start() method only calls the run method. - Start() invokes the run() method on the Thread object. - run method should be present inside every thread to start a new thread. - run() method is used to do an action for a thread. #4 - All threads cannot run at the same time, so threads go for the time sharing. -In this time-sharing Operating system, many processes are allocated with computer resources in respective time slots. - Scheduler is responsible to allow which thread to execute at what time. Github repo : https://github.com/navinreddy20/Javacode.git More Learning : Java :- https://bit.ly/3x6rr0N Python :- https://bit.ly/3GRc7JX Django :- https://bit.ly/3MmoJK6 JavaScript :- https://bit.ly/3tiAlHo Node JS :- https://bit.ly/3GT4liq Rest Api :-https://bit.ly/3MjhZwt Servlet :- https://bit.ly/3Q7eA7k Spring Framework :- https://bit.ly/3xi7buh Design Patterns in Java :- https://bit.ly/3MocXiq Docker :- https://bit.ly/3xjWzLA Blockchain Tutorial :- https://bit.ly/3NSbOkc Corda Tutorial:- https://bit.ly/3thbUKa Hyperledger Fabric :- https://bit.ly/38RZCRB NoSQL Tutorial :- https://bit.ly/3aJpRuc Mysql Tutorial :- https://bit.ly/3thpr4L Data Structures using Java :- https://bit.ly/3MuJa7S Git Tutorial :- https://bit.ly/3NXyCPu Donation: PayPal Id : navinreddy20 https://www.telusko.com

Top Comments (10)

@Mona-3 2023-07-08

Every one searching thread app and I am searching thread in java😢😢

173 6 replies
@dhanvanthnarayanan7604 2024-05-03

The analogy you gave for the two functions - start() and run() is something I would tell even if you were to wake me up and ask in the middle of my sleep holy smokes man , such a good explanation keep up your good work sensei arigato !!!

30
@roshansreevastavroshansree6542 2024-07-02

00:03 Threads are often automatically created by frameworks in applications. 01:31 Two classes with different names and methods are created and objects are created to call the methods 02:52 Execution of show method causes a hold on the main method until it is done executing 04:19 Executing multiple behaviors simultaneously using threads. 05:54 Creating two new threads in Java 07:18 In Java, when using threads, the start method does not directly call the run method. 08:46 Parallel execution of code using multiple threads 10:13 Time-sharing scheduler allows executing multiple threads on a CPU with limited cores.

10
@krishnamoorthysridhar8536 2023-07-08

Sir, Excellent Explanation.. The way of explaining the concept is so clear. Thanks a lot..

10
@saurabhsharma5137 2025-04-17

the best java playlist you can find on the internet

4
@gilberthg3868 2023-10-14

So cool man, you explained the concept of the thread working in computer, while the other course don't. Really appreciate it! Thanks!

3
@ParthShahgg 2025-04-08

Thanks sir made this thing so simple to understand while it felt something crazy while in college lectures.

1
@taha7shaikh 2023-06-20

Thank you very very much, your way of explanation is really amazing

1
@abishekathangaselvam6673 2023-12-25

Excellent sir,u r really great many u tubes simply waste peoples time ,the time become precious or investment if spending on watching ur tutorials,no college tutors taught as how u r teaching hands up sir ❤❤❤

1
@vaishali5.a 2023-10-06

Excellently explained. Thank you so much

0

Unlock the Data Inside
Turn Videos into Knowledge

  • Get FREE 10/day: transcripts, summaries, chats
  • Chat with videos, export text & PDF
  • $1 free API credit for RAG, chatbots & research

Free forever plan • All features unlocked

App screenshot