java - why the setIsrunning(false) method ‘s caller is "main" Thread -


public class run { public static void main(string[] args) {     try{         runthreas runthreas=new runthreas();         runthreas.start();         //thread.sleep(2000);         runthreas.setisrunning(false);         system.out.println("已经赋值为false");     }catch (exception e){         e.printstacktrace();     } } }   class runthreas extends thread{  private boolean isrunning=true;  public boolean isrunning(){     return isrunning; }  public void setisrunning(boolean isrunning){     system.out.println(thread.currentthread().getname()+"set");     this.isrunning=isrunning; }  @override public void run() {     super.run();     system.out.println(thread.currentthread().getname()+"run");     system.out.println("进入run");     while(isrunning){         system.out.println("i running");     }      system.out.println("线程被停止了"); } } 

the setisrunnning() method belongs runthread,so think should called instanse of runthread, invoked thread "main". want know it's why?


Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

python - pip wont install .WHL files -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -