java98-线程join使用中断进行另一个


public class test33 {
    public  static void main(String[] args) {
        Xc46 xc46=new Xc46();
        Thread dd = new Thread(xc46);
        dd.start();
 
            try {
                dd.join();
            } catch (Exception e) {
            }
            for (int i=0;i<15;i++) {
                System.out.println("主函数"+i);
            }
        }
}
class Xc46 implements Runnable {
    public void run() {
        for (int i = 0; i < 30; i++) {
            System.out.println( "歌谣" + i);
        }
    }
}
运行结果

 

posted @ 2022-06-25 15:26  前端导师歌谣  阅读(35)  评论(0)    收藏  举报