线程切换
//1、主线程新建子线程,子线程执行完后调用interface回调主线程,回调函数中代码跑在主线程还是子线程?
public class T803 {
public static void main(String[] args) {
//获得当前线程的名称
System.out.println("main:"+Thread.currentThread().getName());
final TT tt=new TT(){
@Override
public void finish() {
System.out.println("finish:"+Thread.currentThread().getName());
}
};
new Thread(){
public void run() {
System.out.println("new Thread run:"+Thread.currentThread().getName());
tt.finish();
};
}.start();
}
public interface TT{
void finish();
}
}