Try interrupt() the thread as well, which will cause any wait-state
(wait(...), sleep(...)) to end and throw an interrupt exception.
Also, try to not only close the socket by the mmlnStream as well.


On Aug 6, 4:03 pm, cas <[email protected]> wrote:
> Hi
>
> Here is a thread example in Android SDK sample (BluetoothChat)
>
>             while (true) {
>                 try {
>                     // Read from the InputStream
>                     bytes = mmInStream.read(buffer);
>
>                     // Send the obtained bytes to the UI Activity
>                     mHandler.obtainMessage(BluetoothChat.MESSAGE_READ,
> bytes, -1, buffer)
>                             .sendToTarget();
>                 } catch (IOException e) {
>                     Log.e(TAG, "disconnected", e);
>                     connectionLost();
>                     break;
>                 }
>             }
>
> In order to destroy this thread, first to close the socket. But this
> thread is still running at the blocked call mmInStream.read() even
> mSocket.close is successfully run.
>
> Question: How to properly destroy a thread stuck in blocked call?
>
> Thanks and regards.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to