日期:2014-05-18  浏览次数:20727 次

jsp如何加载一个线程,如何关闭一个线程
如题,谢谢了

------解决方案--------------------
启动线程
<%
MyThread theThread= new MyThread();
theThread.start();
%>

线程执行完毕自然会停止,或者如果是一个守护线程的话,可以在线程run方法中用while(!isStop)控制.
<%
theThread.setStop(false);
%>

如果还想得到线程执行的结果,可以在线程中实现一个getRunResult方法:
<%
theThread.getRunResult();
%>
注意getRunResult只能在线程执行完任务以后才能得到真正的结果.