我有一个客户端与服务器通信,该服务器在等待4秒后返回响应(由servlet),然后继续处理。
问题是服务器响应(200 OK)在所有治疗结束时返回,而不是在4秒暂停后返回。我不明白为什么
以下是我的代码片段
try {
mimeTraitement.getMime(client);
mimeTraitement.analyseMime(xmlDir);
if (mimeTraitement.checkMime()) {
System.out.println("Acquittement de la requete dans " + BeanParametrageTimers.getTimeWaitResponseOkToRequest()/1000+ " secondes");
synchronized(response)
{
try {
response.wait(BeanParametrageTimers.getTimeWaitResponseOkToRequest());
} catch (InterruptedException e1) {
e1.printStackTrace();
}
}
writer.write("200 OK (MimeMultipart valide)");// this line is displayed after the processing of postXml.sendXml() on my java console
PostXml postXml = new PostXml(xmlDir,mimeTraitement.getGetUrl());
System.out.println("Envoi du fichier xml dans " + BeanParametrageTimers.getTimeWaitSendXmlToRequest()/1000 + " secondes");
Thread.sleep(BeanParametrageTimers.getTimeWaitSendXmlToRequest());
postXml.sendXml();
} else
writer.write("400 POK (MimeMultipart non valide)");
} catch (MessagingException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
非常感谢