package com.tiantian.servlet;
import com.tiantian.pub.MyTask;
import javax.servlet.*;
import javax.servlet.http.*;
public class TimerListener extends HttpServlet implements
ServletContextListener {
private java.util.Timer timer = null;
public void contextInitialized(ServletContextEvent event) {
timer = new java.util.Timer(true);
timer.schedule(new MyTask(event.getServletContext()), 0, 1000 * 10);
}
public void contextDestroyed(ServletContextEvent event) {
timer.cancel();
}
}
package com.tiantian.pub;
import java.util.TimerTask;
import javax.servlet.ServletContext;
public class MyTask extends TimerTask {
private ServletContext context = null;
public MyTask(ServletContext context) {
this.context = context;
}
public void run() {
context.log("RUNNING..." + System.currentTimeMillis());
}
}
1s=1000ms...
if u encountered puzzle, ask reference for advice.
分享到:
相关推荐
5)....Fixed: Dialog auto-close timer may reset without user input 6)....Fixed: Possible hang when quickly loading/unloading EurekaLog-enabled DLL 7)....Fixed: Possible hang in COM DLLs 8)....Fixed: ...
It can post messages and recieve messages through the internet.<END><br>8 , optiondemo.zip This example demonstrates how to create realistic Option Buttons in Visual Basic.<END><br>9 , mencrypt....
The method of inserting into MSWord may be more useful to most of you..<END><br>48,stopw.zip Example of a stopwatch which does not use a timer control for the calculations, just a simple ...
Please do not post any solutions on a publicly-available Web site. We’ll be happy to provide a copy (up-to-date) of this solution manual ourselves to anyone who asks. Acknowledgments: Over the ...
There are two mini projects included here. The first is called SlotDemo and allows you to send messages or data in a client/server type role. Its uses some very clever programming.<END><br>60 , ...
I can't list all contributors here but I want to specially thanks two specially active contributors: - Arno Garrels <arno.garrels@gmx.de> - Angus Robertson <angus@magsys.co.uk> Latest versions: --...
Theoretically a b+tree is O(N log k N) or log base k of N, now for the typical values of k which are above 200 for example the b+tree should outperform any binary tree because it will use less ...
Here is a summary of all changes that have been made in each version of BurnInTest. Release 5.3 build 1035 revision 4 WIN32 release 10 November 2008 - Lenovo China specific build. Lenovo system ...
Changes in 2.4.6 (February 22, 2011): Brief summary : - Support more host OS to run on: - Include win64 native binary in the release. - Fixed failures on big endian hosts. - BIOS: Support for up to...