What is Multithreading in java . - LearnHowToCode SarkariResult.com Interview Questions and Answers LearnHowToCodeOnline
Multithreading.

What is Multithreading in java .

 Multithreading :

Multithreading in java process of execution of multiple thread parallel it's called that multithreading.

Thread Creating Extending the Thread Class.

We create a class that extends the java.lang.Thread class  . that 's overrides the run() method that will available in thread class ,



class Multithreading extends Thread
{
    public void run()
    {
        try
        {
           
            System.out.println ("Thread " +
                  Thread.currentThread().getId() +
                  " is running");
  
        }
        catch (Exception e)
        {
       
            System.out.println ("catch block will be executing ");
        }
    }
}
  

public class Multithread
{
    public static void main(String[] args)
    {
        int n = 8;
        for (int i=0; i<8; i++)
        {
            Multithreading object = new Multithreading();
            object.start();
        }
    }
}



Output

Thread 8 is running
Thread 9 is running
Thread 10 is running
Thread 11 is running
Thread 12 is running
Thread 13 is running
Thread 14 is running
Thread 15 is running  
If you want learn  deep about multithreading then follow this tutorial 
free tutorial avilable on udemy https://www.udemy.com/course/java-multithreading/ url click bellow down link 




About EasyToCode

I'm Ethan Mariano a software engineer by profession and reader/writter by passion.I have good understanding and knowledge of AngularJS, Database, javascript, web development, digital marketing and exploring other technologies related to Software development.

0 comments:

Featured post

Political Full Forms List

Acronym Full Form MLA Member of Legislative Assembly RSS Really Simple Syndication, Rashtriya Swayamsevak Sangh UNESCO United Nations E...

Powered by Blogger.