我的业务在JavaBean中,JSP调用这个JavaBean,由于业务计算比较耗时,JSP调用后,浏览器半天才能出来结果。于是把在JavaBean中加了线程,如下:public class Test extends Thread {
public void run() {
Log.x().info("thread start");
try {
for (int i = 0; i < 100; i++) {
Log.x().info("sleep" + i);
Thread.sleep(1000);
}
} catch (Exception e) {
Log.x().info("Exp");
}
Log.x().info("thread end");
} public static void go() {
// Create and start the thread
Thread thread = new Test(); Log.x().info("call thread");
thread.start();
}
}可是上面的代码中的循环只能打印前面几次,然后就没有了,没有发现Exception,请问这个是怎么回事??请问还有什么别的方法可以处理类似问题:异步调用,JMS?AJAX?