Code example for ThreadPoolExecutor

Methods: submit

0
    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? 
        } 
    } 
Experience pair programming with AI  Get Codota for Java