67,515
社区成员
发帖
与我相关
我的任务
分享
public class GetMessageServlet extends HttpServlet {
private static String abc = "123";
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
System.out.println("进入");//第二个请求无法输出
synchronized (abc) {
try {
abc.wait(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
public class GetMessageServlet extends HttpServlet {
private static String abc = "123";
private static final long serialVersionUID = 1L;
public GetMessageServlet() {
super();
}
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("utf-8");
response.setContentType("text/html;charset=utf-8");
String name = request.getParameter("name");
System.out.println(name+":进入");//第二个请求无法输出
synchronized (abc) {
try {
abc.wait(5000);
System.out.println(name+":出来");
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}