Thread,Runnable,Handler,Handler.Callback,Looper,MessageQueue,HandlerThread
新线程的开启:
①
new Thread(new Runnable() {
@Override
public void run(){
//异步执行
}
}).start();
②
class MyThread extends Thread {
@Override
public void run(){
//异步执行
}
}
new MyThread().start();
③
class MyRunnable implements Runnable {
@Overrid
public void run(){
//异步执行
}
}
new Thread(new MyRunnable()).start();
Runnable:
按抠脚的英语理解的是,Runnable接口被实现后,必须要用Thread类开启线程,Runnable的设计理念是提供一个公共的方法执行内容。Runnable不一定要用new Thread()的方法来实例化Runnable,也可以用继承Thread来重写run()方法。
Handler
①
class MyThread extends Thread {
private Handler myHandler;
@Override
public void run() {
Looper.prepare();//