浏览代码

sessionCounter同步

tangss 7 年之前
父节点
当前提交
b99ed96b97
共有 1 个文件被更改,包括 2 次插入2 次删除
  1. 2 2
      mooctest-site-server/src/main/java/cn/iselab/mooctest/site/web/SessionCounter.java

+ 2 - 2
mooctest-site-server/src/main/java/cn/iselab/mooctest/site/web/SessionCounter.java

@@ -24,7 +24,7 @@ public class SessionCounter  implements HttpSessionListener {
     private static String dateStart = "2018-02-28";
 
     @Override
-    public void sessionCreated(HttpSessionEvent httpSessionEvent) {
+    public synchronized void sessionCreated(HttpSessionEvent httpSessionEvent) {
         activeSessions++;
 
         SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
@@ -42,7 +42,7 @@ public class SessionCounter  implements HttpSessionListener {
     }
 
     @Override
-    public void sessionDestroyed(HttpSessionEvent httpSessionEvent) {
+    public synchronized void sessionDestroyed(HttpSessionEvent httpSessionEvent) {
         if(activeSessions>0){
             activeSessions--;
             LOG.info("session sessionDestroyed with session id "+httpSessionEvent.getSession().getId() +" and session count "+activeSessions);