on 04-13-2007 10:36 AM
i deploy my EAR application with EJB and WEB ...
i run a timertask...
timer t1=new timer();
t1.schedule(task,0,180*1000); //every 3 minutes run...
the thread cannot stopped...eventhough i stop the EAR that deploy in the application..or even i change my code take take out the timer...
the timer still active..
wat do you think
public class PoolingOutMailAck implements ServletContextListener {
/**
*
*/
TimerTask t1;
Timer outMailAckTimer;
OutMailAckPooling outMailAckPool=new OutMailAckPooling();
public PoolingOutMailAck() {
super();
// TODO Auto-generated constructor stub
}
/* (non-Javadoc)
* @see javax.servlet.ServletContextListener#contextInitialized(javax.servlet.ServletContextEvent)
*/
public void contextInitialized(ServletContextEvent arg0) {
// TODO Auto-generated method stub
outMailAckTimer=new Timer();
outMailAckTimer.schedule(outMailAckPool,0,300*1000);
}
/* (non-Javadoc)
* @see javax.servlet.ServletContextListener#contextDestroyed(javax.servlet.ServletContextEvent)
*/
public void contextDestroyed(ServletContextEvent arg0) {
}
Message was edited by:
yzme yzme
yzme,
It's stricly not recommended to use Java threads management in EJB projects. java.uitl.Timer uses threads underneath, so you are violating this restriction and hence getting unpredictable/wrong results. Actually, Timer is designed to be used by client-side Java programs (desktop applications, applets) rather then by server-side ones.
The better option is to use <a href="http://help.sap.com/saphelp_webas630/helpdata/en/6b/2550d23ef1994580114d6064bc44a1/frameset.htm">Timeout Service</a>. Also see excellent post <a href="/people/maksim.rashchynski/blog/2006/08/07/intercomponent-parameters-exchange">Intercomponent parameters exchange</a> by <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.sdn.businesscard.sdnbusinesscard?u=pyouhggpqqi%3d">maksim Rashchynski</a> for advanced example of Timeout Service usage.
Valery Silaev
SaM Solutions
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.