源程序:
package servlet;import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.lang.*;
import javabean.Auto_Msg_Thread;public class MSG extends HttpServlet {
private static final String CONTENT_TYPE = "text/html; charset=GBK"; //Initialize global variables
public void init() throws ServletException {
System.out.println("init()----------------------");
Runnable r=new Auto_Msg_Thread();// 1
Thread t=new Thread(r);//2
t.start();//3 } //Process the HTTP Get request
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType(CONTENT_TYPE);
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head><title>MSG</title></head>");
out.println("<body bgcolor=\"#ffffff\">");
out.println("<p>The servlet has received a GET. This is the reply.</p>");
out.println("</body></html>");
} //Clean up resources
public void destroy() {
}
}报错信息:
java.lang.IncompatibleClassChangeError at java.lang.Thread.run(Thread.java:534)服务器为tomcat请高手帮忙~!
package servlet;import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.lang.*;
import javabean.Auto_Msg_Thread;public class MSG extends HttpServlet {
private static final String CONTENT_TYPE = "text/html; charset=GBK"; //Initialize global variables
public void init() throws ServletException {
System.out.println("init()----------------------");
Runnable r=new Auto_Msg_Thread();// 1
Thread t=new Thread(r);//2
t.start();//3 } //Process the HTTP Get request
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType(CONTENT_TYPE);
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head><title>MSG</title></head>");
out.println("<body bgcolor=\"#ffffff\">");
out.println("<p>The servlet has received a GET. This is the reply.</p>");
out.println("</body></html>");
} //Clean up resources
public void destroy() {
}
}报错信息:
java.lang.IncompatibleClassChangeError at java.lang.Thread.run(Thread.java:534)服务器为tomcat请高手帮忙~!
另:你这样写可能会出现多个线程