超时请求异常-2
package com.it;
public class TimeoutException extends RuntimeException {
/**
* 序列化号
*/
private static final long serialVersionUID = -8078853655388692688L;
public TimeoutException(String errMessage) {
super(errMessage);
//使用方法:
//初始化超时类
TimeoutThread t = new TimeoutThread(5000,new TimeoutException("超时"));
try{
t.start();
t.cancel();
}catch (TimeoutException e) {
e.printStackTrace();
}
}
}