1.方法一:业务逻辑Runnable与线程控制Thread分离
public class Test implements Runnable{ @Override public void run(){ } } public class MyProject{ Test test = new Test(); Thread t = new Thread(test,"t-name"); t.start(); }
2. 方法二
public class Do{ public void Play(){ } public void Sing(){ } } public class MyProject{ public static void main(String[] args){ new Thread(Do::Play).start();
//or
new Thread(()->{ //Todo }).start();
} }