These threads are created by the system and come from a pool. It's perfectly normal to see them in the debug window. Note that these threads are not necessarily running.
On Thu, Dec 24, 2009 at 10:43 PM, androidsdk166 <[email protected]> wrote: > After this thread run dozens of loops. The Binder Threads are created, > and can be seen in the eclipse debug window. And these Binder Threads > will never get terminated / released. Where does theme come from? How > to prevent this from happening? Or how to get it teminated / released? > > > > public class TServer { > > static final int HTTP_PORT = 7788; > private static Context FContext = null; > > static class RequestListenerThread extends Thread { > > private final ServerSocket serversocket; > private final HttpParams params; > > public RequestListenerThread(Context AContext) throws > IOException { > FContext = AContext; > > this.serversocket = new ServerSocket(HTTP_PORT); > this.params = new BasicHttpParams(); > this.params > > .setIntParameter(CoreConnectionPNames.SO_TIMEOUT, 5000) > > .setIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, > 8 * 1024) > .setBooleanParameter( > > CoreConnectionPNames.STALE_CONNECTION_CHECK, false) > > .setBooleanParameter(CoreConnectionPNames.TCP_NODELAY, true); > // .setParameter(CoreProtocolPNames.ORIGIN_SERVER, > // "HttpComponents/1.1"); > > } > > public void terminate() { > try { > serversocket.close(); > this.interrupt(); > } catch (Throwable e) { > e.printStackTrace(); > } > } > > public void run() { > while (!Thread.interrupted()) { > try { > // Set up HTTP connection > Socket socket = > this.serversocket.accept(); > DefaultHttpServerConnection conn = new > DefaultHttpServerConnection > (); > conn.bind(socket, this.params); > > try { > String aUrl = ""; > String aRequest = ""; > HttpRequest request = > conn.receiveRequestHeader(); > if (request instanceof > HttpEntityEnclosingRequest) { > conn > > .receiveRequestEntity((HttpEntityEnclosingRequest) request); > HttpEntity entity = > ((HttpEntityEnclosingRequest) request) > > .getEntity(); > if (entity != null) { > aRequest = > EntityUtils > > .toString(entity, "UTF-8"); > > entity.consumeContent(); > } > } > aUrl = > request.getRequestLine().getUri(); > > String aResponse = > "中文中文中文中文中文中文中文中文中文"; > > ContentResolver r = > FContext.getContentResolver(); > Cursor c = > r.query(Contacts.People.CONTENT_URI, null, > null, null, > null); > try { > while (c.moveToNext()) > { > aResponse = > aResponse.concat(c.getString(c > > .getColumnIndex(Contacts.People.NAME))); > if > (c.getPosition() > 30) { > break; > } > } > } finally { > c.close(); > } > > HttpResponse response = new > BasicHttpResponse( > > HttpVersion.HTTP_1_0, 200, "OK"); > response > .setEntity(new > StringEntity(aResponse, "UTF-8")); > > conn.sendResponseHeader(response); > > conn.sendResponseEntity(response); > } catch (Throwable e) { > e.printStackTrace(); > } finally { > try { > conn.shutdown(); > } catch (Throwable ignore) { > } > } > > } catch (InterruptedIOException ex) { > ex.printStackTrace(); > // break; > } catch (IOException e) { > e.printStackTrace(); > // break; > } catch (Throwable e) { > e.printStackTrace(); > // break; > } > } > } > } > > } > > -- > 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 > -- Romain Guy Android framework engineer [email protected] Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them -- 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

