我有一个线程接收从服务器发送的地图点,这些点被添加到MapView
. 这很好用,但是如果我与MapView
(例如放大、平移等)进行交互,我会得到一个ConcurrentModificationException
,那么如何在向 中添加点时允许访问用户MapView
?
02-20 01:44:26.566: E/AndroidRuntime(9448): FATAL EXCEPTION: main
02-20 01:44:26.566: E/AndroidRuntime(9448): java.util.ConcurrentModificationException
02-20 01:44:26.566: E/AndroidRuntime(9448): at java.util.ArrayList$ArrayListIterator.next(ArrayList.java:569)
02-20 01:44:26.566: E/AndroidRuntime(9448): at com.google.android.maps.OverlayBundle.draw(OverlayBundle.java:41)
02-20 01:44:26.566: E/AndroidRuntime(9448): at com.google.android.maps.MapView.onDraw(MapView.java:532)
02-20 01:44:26.566: E/AndroidRuntime(9448): at android.view.View.draw(View.java:13707)
02-20 01:44:26.566: E/AndroidRuntime(9448): at android.view.View.draw(View.java:13591)
02-20 01:44:26.566: E/AndroidRuntime(9448): at android.view.ViewGroup.drawChild(ViewGroup.java:2928)
02-20 01:44:26.566: E/AndroidRuntime(9448): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2797)
02-20 01:44:26.566: E/AndroidRuntime(9448): at android.view.View.draw(View.java:13589)
02-20 01:44:26.566: E/AndroidRuntime(9448): at android.view.ViewGroup.drawChild(ViewGroup.java:2928)
02-20 01:44:26.566: E/AndroidRuntime(9448): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2797)
02-20 01:44:26.566: E/AndroidRuntime(9448): at android.view.View.draw(View.java:13589)
02-20 01:44:26.566: E/AndroidRuntime(9448): at android.view.ViewGroup.drawChild(ViewGroup.java:2928)
02-20 01:44:26.566: E/AndroidRuntime(9448): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2797)
02-20 01:44:26.566: E/AndroidRuntime(9448): at android.view.View.draw(View.java:13589)
02-20 01:44:26.566: E/AndroidRuntime(9448): at android.view.ViewGroup.drawChild(ViewGroup.java:2928)
02-20 01:44:26.566: E/AndroidRuntime(9448): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2797)
02-20 01:44:26.566: E/AndroidRuntime(9448): at android.view.View.draw(View.java:13710)
02-20 01:44:26.566: E/AndroidRuntime(9448): at android.widget.FrameLayout.draw(FrameLayout.java:467)
02-20 01:44:26.566: E/AndroidRuntime(9448): at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:2211)
02-20 01:44:26.566: E/AndroidRuntime(9448): at android.view.ViewRootImpl.drawSoftware(ViewRootImpl.java:2281)
02-20 01:44:26.566: E/AndroidRuntime(9448): at android.view.ViewRootImpl.draw(ViewRootImpl.java:2177)
02-20 01:44:26.566: E/AndroidRuntime(9448): at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2045)
02-20 01:44:26.566: E/AndroidRuntime(9448): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1854)
02-20 01:44:26.566: E/AndroidRuntime(9448): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:989)
02-20 01:44:26.566: E/AndroidRuntime(9448): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4351)
02-20 01:44:26.566: E/AndroidRuntime(9448): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
02-20 01:44:26.566: E/AndroidRuntime(9448): at android.view.Choreographer.doCallbacks(Choreographer.java:562)
02-20 01:44:26.566: E/AndroidRuntime(9448): at android.view.Choreographer.doFrame(Choreographer.java:532)
02-20 01:44:26.566: E/AndroidRuntime(9448): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)
02-20 01:44:26.566: E/AndroidRuntime(9448): at android.os.Handler.handleCallback(Handler.java:725)
02-20 01:44:26.566: E/AndroidRuntime(9448): at android.os.Handler.dispatchMessage(Handler.java:92)
02-20 01:44:26.566: E/AndroidRuntime(9448): at android.os.Looper.loop(Looper.java:137)
02-20 01:44:26.566: E/AndroidRuntime(9448): at android.app.ActivityThread.main(ActivityThread.java:5039)
02-20 01:44:26.566: E/AndroidRuntime(9448): at java.lang.reflect.Method.invokeNative(Native Method)
02-20 01:44:26.566: E/AndroidRuntime(9448): at java.lang.reflect.Method.invoke(Method.java:511)
02-20 01:44:26.566: E/AndroidRuntime(9448): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
02-20 01:44:26.566: E/AndroidRuntime(9448): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
02-20 01:44:26.566: E/AndroidRuntime(9448): at dalvik.system.NativeStart.main(Native Method)