Horis 2 лет назад
Родитель
Сommit
761ce2f0fd
1 измененных файлов с 9 добавлено и 4 удалено
  1. 9 4
      app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt

+ 9 - 4
app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt

@@ -320,11 +320,16 @@ class AnalyzeUrl(
         val rateIndex = concurrentRate.indexOf("/")
         var fetchRecord = concurrentRecordMap[source.getKey()]
         if (fetchRecord == null) {
-            fetchRecord = ConcurrentRecord(rateIndex > 0, System.currentTimeMillis(), 1)
-            concurrentRecordMap[source.getKey()] = fetchRecord
-            return fetchRecord
+            synchronized(concurrentRecordMap) {
+                fetchRecord = concurrentRecordMap[source.getKey()]
+                if (fetchRecord == null) {
+                    fetchRecord = ConcurrentRecord(rateIndex > 0, System.currentTimeMillis(), 1)
+                    concurrentRecordMap[source.getKey()] = fetchRecord
+                    return fetchRecord
+                }
+            }
         }
-        val waitTime: Int = synchronized(fetchRecord) {
+        val waitTime: Int = synchronized(fetchRecord!!) {
             try {
                 if (!fetchRecord.isConcurrent) {
                     //并发控制非 次数/毫秒