From fc94230df2846abdf35d611168cd12865d353bc4 Mon Sep 17 00:00:00 2001 From: "pengfei.zhou" Date: Fri, 17 Jun 2022 10:40:18 +0800 Subject: [PATCH] android: fix java.util.ConcurrentModificationException --- .../performance/DoricPerformanceProfile.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/doric-android/doric/src/main/java/pub/doric/performance/DoricPerformanceProfile.java b/doric-android/doric/src/main/java/pub/doric/performance/DoricPerformanceProfile.java index cd813def..91a34095 100644 --- a/doric-android/doric/src/main/java/pub/doric/performance/DoricPerformanceProfile.java +++ b/doric-android/doric/src/main/java/pub/doric/performance/DoricPerformanceProfile.java @@ -67,12 +67,22 @@ public class DoricPerformanceProfile { return this.name; } - public void addAnchorHook(AnchorHook hook) { - this.hooks.add(hook); + public void addAnchorHook(final AnchorHook hook) { + performanceHandler.post(new Runnable() { + @Override + public void run() { + hooks.add(hook); + } + }); } - public void removeAnchorHook(AnchorHook hook) { - this.hooks.remove(hook); + public void removeAnchorHook(final AnchorHook hook) { + performanceHandler.post(new Runnable() { + @Override + public void run() { + hooks.remove(hook); + } + }); } public void enable(boolean enable) {