how to override thread.start() method in java?

前端 未结 10 1840
情歌与酒
情歌与酒 2020-12-03 02:07

I need to implement thread.start() method in my java code. Please let me know through an example of overriding of thread.start() method and how it works?

10条回答
  •  被撕碎了的回忆
    2020-12-03 03:04

    You don't override the start, you override the "run". You can simply implement a thread by:

    new Thread() {
      public void run() {
        //your code here
      }
    }.start();
    //start will call the logic in your run method
    

提交回复
热议问题