如果要在Web中使用监视线程,
可以在Bean中实现,这样就不会因为页面关闭而退出。
可以在Bean中实现,这样就不会因为页面关闭而退出。
解决方案 »
- 用过DigestUtils.shaHex的请进
- 提问
- 在web工程 关联的工程中定义的类说找不到(请高手指教)
- javamail 发送邮件
- 在精通struts的例子里加了个文本框password,但显示的还是username内容,而不是password提交的内容,怎么回师?????
- mysql中EMUN类型该怎么取??
- commons-fileupload和tomcat5.0.16两个问题,解决后送200分
- JSP与SQLServer2000数据库连接时环境变量的设置问题,谢谢前辈指教
- linux8.0下安装jdk出现如下错误,请高手指教!
- 用Javamail发送邮件时,在transport.connect时停住了
- 紧急求救:jsp对Oracle数据库中long 型数据进行模糊查询 如何查?
- 关于表单提交
package test;public class Watch extends Thread{
private static Watch instance;
private Watch() {
}
public static synchronized Watch getInstance(){
if(instance==null){
instance = new Watch();
}
return instance;
}
public void run(){
int i=0;
while(true){
i++;
try{
sleep(1000);
}catch(InterruptedException ie){}
System.out.println("count: "+i);
}
}
}//test.jsp
<%@ page language="java" %>
<%@ page import ="test.*" %>
<%
Watch aWatch = Watch.getInstance();
aWatch.start();
%>
<html>
<head>
<title></title>
<body></body>
</html>
我怀疑生成页面后线程就自动结束了。是不是这样啊?
什么叫做out.close?多谢多谢!!我实在是太菜了。
不会吧,webwing(kevin) 的代码把浏览器关了都不会死的,你打开控制台,可以看到不断地输出count: 1/2/3/4......
//jsp 里面
KPIReminder rmd = KPIReminder.createReminder();
if (rmd!=null) {
Thread threadRemind = new Thread(rmd);
threadRemind.start();
//class里面
while (!finished){
DebugUtil.output(i);
i++;
Date temp = new java.util.Date();
Date today = new java.sql.Date(temp.getYear(),temp.getMonth(),temp.getDay());
if ((today.before(startDate))||(today.after(evaDeadline))) break;
else Thread.sleep(1000*60);
}
}
}catch (Exception e){
DebugUtil.output(e.toString());
}
}