java線程--打印錯誤堆棧信息

public class Test {

    static class MyTask implements Runnable {

        int a,b;
        public MyTask(int a,int b){
            this.a=a;
            this.b=b;
        }

        @Override
        public void run() {

            System.out.println(a/b);
        }

    }

    public static void main(String[] args) {

        
        ExecutorService exs = Executors.newFixedThreadPool(5);
        
        for(int i=0;i<5;i++){
            MyTask t = new MyTask(10,i);
            exs.execute(t);
        }

        exs.shutdown();
    }

}
相關文章
相關標籤/搜索