MultiTasking Using Thread,Showing two thread working simultaneously - LearnHowToCode SarkariResult.com Interview Questions and Answers LearnHowToCodeOnline
MultiTasking Using Thread

MultiTasking Using Thread,Showing two thread working simultaneously

MultiTasking Using Thread,


class MyThread implements Runnable
  {
   String str;
   MyThread(String str)
   {
      this.str=str;
  }
  public void  run()
  {
   for(int i=1;i<=10; i++)
   {
   System.out.println(str+":"+i);
   try{
      Thread.sleep(2000);
  }
  catch(InterruptedException ie)
  {
  ie.printStackTrace();
  }
}
}
   }
 
  class Main
  {
    public static void main(String args[])
{
MyThread mt1=new MyThread("Cut the ticket");
MyThread mt2=new MyThread("show the Seat");
Thread t1=new Thread(mt1);
Thread t2=new Thread(mt2);
t1.start();
t2.start();
}
}




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.