我的班级内有run-method
,Thread
。 Codesnipp:
public void run() {
Log.i(TAG, "BEGIN mConnectedThread");
byte[] buffer = new byte[1024];
int bytes;
Log.i("INSIDE RUN: ", "STARTING LISTNING FOR INPUTSTREAM" );
// Keep listening to the InputStream while connected
while (true) {
try {
// Read from the InputStream
bytes = mmInStream.read(buffer);
//Log.d("BYTES FROM THE DEVICE: ", Integer.toString(bytes));
} catch (IOException e) {
Log.e(TAG, "disconnected", e);
break;
}
}
}
一段时间后,LogCat给了我以下错误:
07-27 14:51:55.860: E/dalvikvm(17271): threadid=2: stuck on threadid=1187, giving up
我认为这个错误消息试图告诉我的是,就操作系统相关的东西而言,该线程正在进行spinlock
并执行Busy waiting
。但为什么忙着等待,我正在做一些事情,阅读流。任何人都能指出我正确的方向吗?谢谢!