Parcourir la source

取消部分无用的同步锁。

lighter il y a 4 ans
Parent
commit
4c02343835

+ 1 - 1
pom.xml

@@ -10,7 +10,7 @@
     </parent>
     <groupId>thyyxxk</groupId>
     <artifactId>wxservice-server</artifactId>
-    <version>4.1</version>
+    <version>4.2</version>
     <name>wxservice-server</name>
     <description>server for wxservice-web</description>
 

+ 11 - 16
src/main/java/thyyxxk/wxservice_server/service/HomePageService.java

@@ -28,26 +28,21 @@ public class HomePageService {
         if (list.size() > 0) {
             return ResultVoUtil.success(list);
         }
-        synchronized (list) {
-            if (list.size() > 0) {
-                return ResultVoUtil.success(list);
+        List<HomePageDoctor> originList = dao.selectHomePageDoctors();
+        List<HomePageDoctor> tempList = new ArrayList<>();
+        for (HomePageDoctor doctor : originList) {
+            if (null == doctor.getIntroduction() || doctor.getIntroduction().equals("")) {
+                continue;
             }
-            List<HomePageDoctor> originList = dao.selectHomePageDoctors();
-            List<HomePageDoctor> tempList = new ArrayList<>();
-            for (HomePageDoctor doctor : originList) {
-                if (null == doctor.getIntroduction() || doctor.getIntroduction().equals("")) {
-                    continue;
-                }
-                tempList.add(doctor);
-                if (tempList.size() == 3) {
-                    list.add(tempList);
-                    tempList = new ArrayList<>();
-                }
-            }
-            if (tempList.size() > 0) {
+            tempList.add(doctor);
+            if (tempList.size() == 3) {
                 list.add(tempList);
+                tempList = new ArrayList<>();
             }
         }
+        if (tempList.size() > 0) {
+            list.add(tempList);
+        }
         return ResultVoUtil.success(list);
     }
 

+ 4 - 1
src/main/java/thyyxxk/wxservice_server/utils/PropertiesUtil.java

@@ -1,11 +1,14 @@
 package thyyxxk.wxservice_server.utils;
 
+import org.springframework.stereotype.Component;
+
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.nio.charset.StandardCharsets;
 import java.util.Properties;
 
+@Component
 public class PropertiesUtil {
     private static Properties props;
 
@@ -13,7 +16,7 @@ public class PropertiesUtil {
         loadProps();
     }
 
-    synchronized static private void loadProps() {
+    static private void loadProps() {
         props = new Properties();
         InputStream in = null;
         try {

+ 1 - 1
src/main/resources/application-prod.yml

@@ -1,5 +1,5 @@
 server:
-  port: 8085
+  port: 8083
   servlet:
     context-path: /wxserver
 spring: