码迷,mamicode.com
首页 > 移动开发 > 详细

Android While 循环导致的资源占用过高进而导致程序崩溃问题

时间:2016-04-14 17:31:35      阅读:549      评论:0      收藏:0      [点我收藏+]

标签:

Timeline: Activity_launch_request time:65620
04-14 15:31:25.347: I/dalvikvm(3483): Total arena pages for JIT: 11
04-14 15:31:25.621: D/dalvikvm(3483): JIT unchain all for threadid=13
04-14 15:31:26.371: W/dalvikvm(3483): threadid=1: spin on suspend #1 threadid=13 (pcf=0)
04-14 15:31:27.122: W/dalvikvm(3483): threadid=1: spin on suspend #2 threadid=13 (pcf=0)
04-14 15:31:27.122: I/dalvikvm(3483): "main" prio=5 tid=1 RUNNABLE

 

JIT unchain all for threadid=19

04-14 15:33:28.638: W/dalvikvm(5595): threadid=20: spin on suspend #1 threadid=19 (pcf=0)
04-14 15:33:29.388: W/dalvikvm(5595): threadid=20: spin on suspend #2 threadid=19 (pcf=0)
04-14 15:33:29.388: I/dalvikvm(5595): "pool-5-thread-2" prio=5 tid=20 RUNNABLE

 

运行应用过程中多次调用While(!isComplete); 对线程进行阻塞,导致线程资源占用过高。修改为一下实现方式可以降低资源占用

while(!isComplete){

  try {

    Thread.sleep(100);
  } catch (InterruptedException e) {
  // TODO Auto-generated catch block
    Log.e(e);
  }
  continue;

}

 

Android While 循环导致的资源占用过高进而导致程序崩溃问题

标签:

原文地址:http://www.cnblogs.com/inbase/p/5391736.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!