Explorar el Código

sessionCounter同步

tangss hace 7 años
padre
commit
b99ed96b97

+ 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);