超时
2016-04-18 15:00
204 查看
1. tomcat的session超时怎么做的
有专门的后台线程每隔10秒(sleep 10l,可以配置)处理一次是否过期
专门的线程
org.apache.catalina.core.ContainerBase.ContainerBackgroundProcessor
触发过期检查的地方:
Thread.sleep(backgroundProcessorDelay * 1000L); backgroundProcessorDelay 秒钟检查一次。backgroundProcessorDelay 在StandardEngine设置的是10 也就是10s钟检查一次。可以理解成session超时默认精度10s
处理是否过期
处理过期的具体方法:
org.apache.catalina.session.StandardSession.expire(boolean)
--EOF--
有专门的后台线程每隔10秒(sleep 10l,可以配置)处理一次是否过期
专门的线程
org.apache.catalina.core.ContainerBase.ContainerBackgroundProcessor
触发过期检查的地方:
public void run() { while (!threadDone) { try { Thread.sleep(backgroundProcessorDelay * 1000L); } catch (InterruptedException e) { ; } if (!threadDone) { Container parent = (Container) getMappingObject(); ClassLoader cl = Thread.currentThread().getContextClassLoader(); if (parent.getLoader() != null) { cl = parent.getLoader().getClassLoader(); } processChildren(parent, cl); } } }
Thread.sleep(backgroundProcessorDelay * 1000L); backgroundProcessorDelay 秒钟检查一次。backgroundProcessorDelay 在StandardEngine设置的是10 也就是10s钟检查一次。可以理解成session超时默认精度10s
threadDone 这个标志会在stop的时候置成true,以使得能循环能正常结束
处理是否过期
if (maxInactiveInterval >= 0) { long timeNow = System.currentTimeMillis(); int timeIdle = (int) ((timeNow - thisAccessedTime) / 1000L); if (timeIdle >= maxInactiveInterval) { expire(true); } }
处理过期的具体方法:
org.apache.catalina.session.StandardSession.expire(boolean)
--EOF--
相关文章推荐
- 提示Can't load package:dclite70.bpl解决方法
- Android中的Interpolator
- autopackstepCompile-BASE.bat
- Linux命令分类
- HUD 1881 毕业bg(01背包变形)
- Android中使用NDK
- CF 379A New Year Candles
- hibernate openSession和getCurrentSession区别和联系、get和load的区别
- javascript code snippet -- Forwarding Mouse Events Through Layers
- 怎么预览 GitHub 项目里的网页或 Demo?
- 如何取得“深交所投资者服务密码”
- 2164: 采矿|树链剖分|DP
- autopackstepARES1-BASE.bat
- initNEW2-BASE.bat
- java集合-TreeSet
- R-CNN笔记0:README.md文件
- Android studio 导入github工程
- 动态规划
- The C programing language chapter 7 : Input and Output
- 设计模式之装饰器模式