Code example for ThreadPoolExecutor

Methods: submit

    private void sendRequest(DefaultHttpClient client, HttpContext httpContext, HttpUriRequest uriRequest, String contentType, AsyncHttpResponseHandler responseHandler, Context context) {
        if(contentType != null) {
            uriRequest.addHeader("Content-Type", contentType);
        Future<?> request = threadPool.submit(new AsyncHttpRequest(client, httpContext, uriRequest, responseHandler));
        if(context != null) {
            // Add request to request map 
            List<WeakReference<Future<?>>> requestList = requestMap.get(context);
            if(requestList == null) {
                requestList = new LinkedList<WeakReference<Future<?>>>();
                requestMap.put(context, requestList);
            requestList.add(new WeakReference<Future<?>>(request));
            // TODO: Remove dead weakrefs from requestLists? 
Connect your IDE to all the code out there  Get Codota for Java