打字猴:1.700450151e+09
1700450151
1700450152 public void run(){
1700450153
1700450154 //正常业务运行,运行3秒
1700450155
1700450156 for(int i=0;i<3;i++){
1700450157
1700450158 try{
1700450159
1700450160 Thread.sleep(1000);
1700450161
1700450162 System.out.println(“系统正常运行:”+i);
1700450163
1700450164 }catch(InterruptedException e){
1700450165
1700450166 e.printStackTrace();
1700450167
1700450168 }
1700450169
1700450170 }
1700450171
1700450172 //抛出异常
1700450173
1700450174 throw new RuntimeException();
1700450175
1700450176 }
1700450177
1700450178 //异常处理器
1700450179
1700450180 private static class TcpServerExceptionHandler implements
1700450181
1700450182 Thread.UncaughtExceptionHandler{
1700450183
1700450184 @Override
1700450185
1700450186 public void uncaughtException(Thread t, Throwable e){
1700450187
1700450188 //记录线程异常信息
1700450189
1700450190 System.out.println(“线程”+t.getName()+“出现异常,自行重启,请分析原因。”);
1700450191
1700450192 e.printStackTrace();
1700450193
1700450194 //重启线程,保证业务不中断
1700450195
1700450196 new TcpServer();
1700450197
1700450198 }
1700450199
1700450200 }
[ 上一页 ]  [ :1.700450151e+09 ]  [ 下一页 ]