创建新类继承Thread
Class MyThread extends Thread{
@Override
public void run(){
}
}
MyThread t=new MyThread();
t.start();
使用Runnable接口
Class MyThread implements Runnable{
@Override
public void run(){
}
}
MyThread t=new MyThread();
new Thread(myThread).start();
使用匿名类
new Thread(new Runnable{
@Override
public void run(){
}
}).start();