 Hello friends, I am Sanjay Gupta. In this video, I am going to demonstrate you how you can implement multithreading by inheriting thread class in Java. Before starting, you can subscribe my YouTube channel by clicking on the link which is available at the bottom right corner of this video. You can download my app Takimiz that is available on Google Play. You can connect with me by following these details which are available in front of you. Now coming on to the topic. For demonstration, I have already implemented this code for you. So you can see that first here class first is defined, which is inheriting thread class. So friends, whenever you want to apply multithreading concept on a class, then you have to inherit thread class. Inside thread class, there is a method which is already available that is run. So you have to override that method and you have to provide certain code inside run method. Here you can see I have implemented for loop, which is starting from 1 and its condition is i less than equals to 10. So this loop will repeat 10 times. It will display first thread message on console through system.out.println. Similar to this definition, class second is implemented, which is also inheriting thread class. Inside second class, run method is overwritten and its definition is provided. It is similar to class first run method. Similar to first and second, third class is implemented, which is also inheriting thread class and run method is overwritten. So friends, you can see that class first, class second and class third, all three classes are inheriting thread class so that we can apply the concept of multithreading on all of these classes and all three classes are overriding run method because whenever we apply multithreading, then all the code which we want to execute must be available inside run method. Now for execution of run method, we have to define another class here that class is test. Inside test class, main method is implemented. So inside main method, objects of all three classes, class first, class second and class third are created. Now I want to call run method of class first, second and third. For that purpose, I have to call start method. So after creation of object of first class, I have called start and start method internally calls run method. Similarly, as dot start, it will call run method of second class and T dot start, it will call run method of third class. So all these start methods will be executed simultaneously and internally they will call run method of their respective classes. So you can imagine that run method of first, second and third classes are executing parallely and with the execution of those run methods, main method is also working. So with the help of this simple demonstration, I hope you have understood how we can apply multithreading concept in Java. Now I'm going to execute this code so that you can see the output. Now you can see the output. Second thread message is printed first, then first thread and then third thread. So friends, in case of multithreading, output will not be fixed all the time. Whenever you want to check the output, you just have to execute your code and you will see the output as per the processing of CPU which thread is processed first by the CPU according to that your output will be displayed on console. So you can see that here second thread is processed first, then first thread and then third thread. So in case of multithreading scenario, all the threads are processing simultaneously. So whenever a particular thread is processed by CPU, its output will be displayed on the console for user and a particular thread which is processed later on that output will be printed later because there is a mechanism of scheduling with processor. According to that, all the threads are executed. So friends, you can implement this code yourself so that you can understand the concept. If you want to watch more programming related videos, you can subscribe my YouTube channel. Thank you for watching this video.