我对我的调试时间错误有一些疑问

时间:2010-10-26 14:54:08

标签: android thread-safety handler

第一

10-26 17:43:07.454: WARN/dalvikvm(6371): threadid=3: unable to interrupt threadid=19
10-26 17:43:07.487: DEBUG/dalvikvm(6371): GC freed 279 objects / 259776 bytes in 208ms
10-26 17:43:07.487: WARN/WindowManager(2215): Attempted to add application window with unknown token HistoryRecord{46366130 spexco.hus.cepvizyon/.ViewCam}.  Aborting.

我现在看不到其他错误,但第二,我想学习如何停止处理程序。 我的处理程序代码是:我用“handler.sendMessage(new Message());”

调用
private Handler handler = new Handler() {
    public void handleMessage(Message msg) {

        try {

            bmp = CameraManagerScreen.ActiveCam.getCurrentImage();
            bmpl = CameraManagerScreen.ActiveCam.getCurrentLenght();
            if (bmpl != bmpltmp) {
                if (speed.getVisibility() == 4) {
                    speed.setVisibility(0);
                    counter++;
                } else {
                    speed.setVisibility(4);
                    counter++;
                }
            }
            bmpltmp = bmpl;

            if (bmp != null) {
                if (CameraManagerScreen.ActiveCam.isConnected())
                    m_ProgressDialog.dismiss();
                imageView.setImageBitmap(bmp);

            }
            if (isDemo && counter == 10) {
                counter++;
                CameraManagerScreen.ActiveCam.cancel();
                CameraManagerScreen.ActiveCam.setConnected(false);

                m2_ProgressDialog.show();

            }

        } catch (Exception e) {

        } finally {
            if (isDemo && counter == 10)
                sleep(999999999);
            sleep(50);
        }

    };

    public void sleep(long delay) {
        this.removeMessages(0);

        sendMessageDelayed(obtainMessage(0), delay);

    };
};

1 个答案:

答案 0 :(得分:0)

当您尝试中断等待线程时出现“无法中断”问题,但线程处于“卡住”状态,因此VM放弃并丢弃中断。

从2.2(“froyo”)开始,线程中断机制发生了变化,不再发生这种情况。

这是否可靠地发生?