public class Test {
public static void main(String[] args) {
Thread t=new Thread(){
public void run() {
fun();
};
};
//注意这里不是启动线程,这是调用Thread类的run方法,启用线程要用t.start()
t.run();
System.out.println("22222222");
}
static void fun(){
System.out.println("1111111");
}
}
输出
1111111
22222222
是启动线程和调用线程的run方法
最新推荐文章于 2024-05-24 08:40:48 发布