超时请求异常-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();
}
}
}

posted @ 2019-05-13 07:39  jareny  阅读(158)  评论(0编辑  收藏  举报