错误堆栈:

java.lang.ArrayIndexOutOfBoundsException: length=0; index=1
at android.support.v4.util.SimpleArrayMap.indexOf(SimpleArrayMap.java:83)
at android.support.v4.util.SimpleArrayMap.put(SimpleArrayMap.java:381)

示例错误代码:

final ArrayMap testArrayMap = new ArrayMap();

        new  Thread("线程1"){
@Override
public void run() {
super.run();
while (true){
testArrayMap.put("aaa","fffff");
}
} }.start(); new Thread("线程2"){
@Override
public void run() {
super.run();
while (true){
testArrayMap.clear();
}
} }.start();

错误原因:

ArrayMap 不支持多行程,请在一个线程里面使用。不然会导致数组越界。如果想在多线程里面使用,请使用HasTable。

google 的 ArrayMap 本身就没有支持多线程,在最新的support 包里面,如果你还多线程使用ArrayMap,就会throw CME (ConcurrentModificationException)

ArrayMap java.lang.ArrayIndexOutOfBoundsException的更多相关文章

  1. Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1

    场景:eclipse中编写java中用到数组 问题: 程序不报错但是运行过程中 终止,显示字样 “ Exception in thread "main" java.lang.Arr ...

  2. java 中 java.lang.ArrayIndexOutOfBoundsException: 0 异常

    package test; public class Test { public static void main(String[] args) { final int num2 = Integer. ...

  3. ListView中使用type需要注意的东西 java.lang.ArrayIndexOutOfBoundsException: length=2; index=2 addScrapView

    ListView中使用type需要注意的东西 在使用ListView时,如果使用了getItemViewType, 记得他的值一定要是从0开始计数的. 且要覆盖getViewTypeCount方法.并 ...

  4. Java - 错误: "java.lang.ArrayIndexOutOfBoundsException: length=1; index=1"

    错误: "java.lang.ArrayIndexOutOfBoundsException: length=1; index=1" 本文地址: http://blog.csdn.n ...

  5. android listview Caused by: java.lang.ArrayIndexOutOfBoundsException: length=3; index=3

    android listview 适配器在多种类型viewType报错: Caused by: java.lang.ArrayIndexOutOfBoundsException: length=3; ...

  6. java.lang.ArrayIndexOutOfBoundsException

    1.错误描述 Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0 at com.you.m ...

  7. Android BaseAdapter加载多个不同的Item布局时出现UncaughtException in Thread main java.lang.ArrayIndexOutOfBoundsException: length=15; index=15

    java.lang.ArrayIndexOutOfBoundsException: length=15; index=15 异常出现的场景:在做聊天界面时,需要插入表情,图片,文字,名片,还有几种较为 ...

  8. Tomcat 或JBOSS java.lang.ArrayIndexOutOfBoundsException: 8192 解决方案【转】

    错误信息: 2017-1-17 10:09:39 org.apache.catalina.core.StandardWrapperValve invoke 严重: Servlet.service() ...

  9. 解决Redisson出现Failed to instantiate [org.redisson.api.RedissonClient]: Factory method 'create' threw exception; nested exception is java.lang.ArrayIndexOutOfBoundsException: 0的问题

    一.背景 最近项目中使用了redisson的哨兵模式来作为redis操作的客户端,然后一个意外出现了,启动报:Failed to instantiate [org.redisson.api.Redis ...

随机推荐

  1. 用PHP向数据库中实现简单的增删改查(纯代码)

    <?php $con = mysql_connect("localhost:3306","root",""); if (!$con) ...

  2. Python:IPC-Pipe与IPC-Manger

    1,IPC-PIPE: 管道 pipe from multiprocessing import Process from multiprocessing import Pipe p1,p2 = Pip ...

  3. 创建maven项目后缺少jar包下载失败等问题

    transfer.......fail.........等问题 The container 'Maven Dependencies' references non existing library ' ...

  4. c#隐藏tabcontrol选项卡

    隐藏:Tab1.TabPage2.Parent = null;显示:Tab1.TabPage2.Parent =Tab1;tab1为tab控件名,TabPage2为选项卡名.

  5. Mysql之inner join,left join,right join详解

    首先借用官方的解释下: inner join(等值连接):只返回两个表中联结字段相等的行: left join(左联接):返回包括左表中的所有记录和右表中联结字段相等的记录: right join(右 ...

  6. 消息中间件JMS(一)

    1.JMS入门 1.1消息中间件 模块之间的依赖也称之为耦合.而耦合越多,之后的维护工作就越困难.那么如果改善系统模块调用关系.减少模块之间的耦合呢?我们接下来就介绍一种解决方案----消息中间件. ...

  7. Python—面向对象 封装03

    接着上面的一篇继续往下: 如何隐藏 在python中用双下划线开头的方式将属性隐藏起来(设置成私有的) class A: __x = 1 # _A__x = 1 def __init__(self, ...

  8. iOS | AFNetworking封装

    为大家分享一个IOS处理网络请求,网络上传,网络下载等功能全面的一个第三方框架-AFNetworking,这是一个使用非常方便的网络框架. 最新的版本是基于NSURLSession,原来的NSURLC ...

  9. MySql使用入门

    SQL是Structure Query Language(结构化查询语言)的缩写. SQL主要可以分为三个类别: 1.DDL(Data Definition Languages)语句:数据定义语言,这 ...

  10. vs2017中的scanf_s

    在visual studio 2017中格式化输入函数不同于其他c/c++编译器使用scanf,而是使用scanf_s. scanf_s相比较于scanf来说更安全,因为使用scanf_s函数需要有一 ...