Terminating the the thread by pressing the enter button in this program - LearnHowToCode SarkariResult.com Interview Questions and Answers LearnHowToCodeOnline
Terminating the the thread by pressing the enter button in this program

Terminating the the thread by pressing the enter button in this program


Terminating the the thread by pressing the enter button in this program

import java.io.*;
class MyThread2 extends Thread{
 boolean stop=false;
 public void run()
 {
   for(int i=1;i<10000;i++)
   {
     System.out.println(i);
if(stop) return;
}
    }
}
class Main2

public static void main(String[]args) throws IOException
{
  MyThread2 mt=new MyThread2();
Thread t=new Thread(mt);
t.start();
mt.stop=true;
}
}
 

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.