public synchronized String test(Base b) throws Exception {
String xmlSign = null;
String url = "http://" + b.getAddress() + ":" + config.gePort();
PostMethod post = new PostMethod(url);
post.setRequestBody(xml);
post.setRequestHeader("Content-Length","");
post.setRequestHeader(" Content-Type", ""); HttpClient client = new HttpClient();
client.getHttpConnectionManager().getParams().setSoTimeout(300000); int result;
try {
result = client.executeMethod(post);
// 返回200为成功
String repContent = post.getResponseBodyAsString();
if (repContent == null || "".equals(repContent)) {
post.releaseConnection();
throw new Exception("签名返回错误:" + repContent);
}
repContent.replaceAll("\n", "");
if (200 == result) {
int beginSign = repContent.indexOf("<a>") + 6;
int endSign = repContent.indexOf("</a>");
xmlSign = repContent.substring(beginSign, endSign);
} else {
post.releaseConnection();
throw new Exception("连接码为:" + repContent);
} // 返回的内容
post.releaseConnection(); // 释放连接
} catch (HttpException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
}
return xmlSign;
}这是不是线程安全的,怎么判断一个线程是不是安全的