错误堆栈:

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. 如何在SAP CRM里创建和消费Web service

    Created by Wang, Jerry, last modified on Dec 19, 2014 The following steps demonstrates how to expose ...

  2. 如何将BSP应用配置成Fiori Launchpad上的一个tile

    当我们通过WebIDE或者Eclipse的插件Team Provider把一个本地开发好的UI5应用部署到了ABAP Netweaver服务器上之后,我们可以将该UI5应用配置成Fiori launc ...

  3. python入门4 python查看数据类型及类型转换

    查看数据类型:type() 类型转换:int(),float(),char(),ord(),str(),bool() #coding:utf-8 #/usr/bin/python "&quo ...

  4. Android坡度计

    艺术来源于生活,对我来说,编程也是一门艺术.今天发布这篇技术博客,就是我跟朋友在一次爬山过程中的争论,他跟我说那座山至少45度,我说没有,最多30度.我们彼此争论不休,于是我就想,为啥不写个手机程序来 ...

  5. IOS 多媒体 使用总结

    一.音频播放 1.音效播放(短时间的音频文件)1> AudioServicesCreateSystemSoundID2> AudioServicesPlaySystemSound 2.音乐 ...

  6. datatable Left and right fixed columns

    $(document).ready(function() { var table = $('#example').DataTable( { scrollY: "300px", sc ...

  7. sql语句更新某字段内容中部分数据

    使用到的sql 语句的关键字就是replace, 如下图,把带有zhangjun 的值替换成 user 使用的sql语句就是 update 表名 set 字段名=replace(字段名,‘替换字符内容 ...

  8. Storm 中drpc调用

    package storm.starter; import backtype.storm.Config; import backtype.storm.LocalCluster; import back ...

  9. linux 使用sqlite3

    :c中使用sqlite3需要调用函数接口操作: sqlite3 *db; int status=sqlite_open("dbname",&db);//打开或者创建数据库 ...

  10. JavaScript js调用堆栈(三)

    本文主要深入介绍JavaScript内存机制 内存模型 JS内存空间分为栈(stack),堆(heap),池(一般也会归类为栈中),其中栈存放变量,堆存放复杂对象,池存放常量. 注:闭包中的变量并不保 ...