2 sachinks SachinKS 于 2013.08.27 11:10 提问

同步LinkedList时报错

代码:

private List<String> requests = Collections.synchronizedList(new LinkedList<String>());

private List<String> requests = Collections.synchronizedList(new LinkedList<String>());

运行报错:

FATAL EXCEPTION: main
java.lang.IllegalStateException: Could not execute method of the activity
    at android.view.View$1.onClick(View.java:2144)
    at android.view.View.performClick(View.java:2485)
    at android.view.View$PerformClick.run(View.java:9080)
    at android.os.Handler.handleCallback(Handler.java:587)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:123)
    at android.app.ActivityThread.main(ActivityThread.java:3683)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:507)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
    at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:507)
    at android.view.View$1.onClick(View.java:2139)
    ... 11 more
Caused by: java.lang.ClassCastException: java.util.Collections$SynchronizedList
    at com.countryst.nabard.turnbased.client.networking.ClientNetworking.login(ClientNetworking.java:72)
    at com.countryst.nabard.turnbased.client.MainActivity.loginToServer(MainActivity.java:87)
    at com.countryst.nabard.turnbased.client.MainActivity.onButtonClicked(MainActivity.java:217)
    ... 14 more
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!