在一个线程组中如果其中一个线程执行报错并不影响其他线程的继续执行,例如:
package com.fyw.thread.lock.exception;
public class MyThread extends Thread {
private String num;
public MyThread(ThreadGroup group,String name,String num) {
super(group,name);
this.num = num;
}
@Override
public void run() {
int numInt = Integer.parseInt(num);
while(true){
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println("死循环执行中:"+Thread.currentThread().getName());
}
}
}
package com.fyw.thread.lock.exception;
public class Run {
public static void main(String[] args) {
ThreadGroup group = new ThreadGroup("自定义线程组");
MyThread[] myThread = new MyThread[10];
for(int i=0;i<myThread.length;i++){
myThread[i] = new MyThread(group,"线程"+(i+1),"1");
myThread[i].start();
}
MyThread newT = new MyTh