本帖最后由 fty13 于 2011-02-16 18:43:53 编辑

解决方案 »

  1.   

    API是这样写的:  
    public final boolean  post  (Runnable r)Causes the Runnable r to be added to the message queue. The runnable will be run on the thread to which this handler is attached. 你把个进度条操作弄的太复杂
      

  2.   

    removeCallbacks仅仅移除了handler,thread一旦执行,java还没有很好的方法结束线程
      

  3.   

    正如3楼所说
    removeHandler 不代表 stop thread。
    2个是异步的过程 
      

  4.   

    哥们,你这个是一个互相调用的无限循环,那肯定会一直执行下去。
    updateBarHandler.sendMessage(msg);
    System.out.println("" + msg.arg1);
    if (i >= 100) {
    System.out.println("in if");
    updateBarHandler.removeCallbacks(updateThread);
    System.out.println("关闭线程语句没起作用"); }
    }
    改为
    System.out.println("" + msg.arg1);
    if (i <= 100) {
    updateBarHandler.sendMessage(msg);
    System.out.println("in if");
    updateBarHandler.removeCallbacks(updateThread);
    System.out.println("关闭线程语句没起作用"); }
    }
    即可。这时候run就结束执行了。