Source:
<code>public GetRevisionTaskThreaded(CouchDB sourceDb, List<BulkGetRequest> requests, boolean pullAttachmentsInline) { Preconditions.checkNotNull(sourceDb, "sourceDb cannot be null"); Preconditions.checkNotNull(requests, "requests cannot be null"); for(BulkGetRequest request : requests) { Preconditions.checkNotNull(request.id, "id cannot be null"); Preconditions.checkNotNull(request.revs, "revs cannot be null"); } this.sourceDb = sourceDb; this.requests = requests; this.pullAttachmentsInline = pullAttachmentsInline; <START> this.executorService = new ThreadPoolExecutor(threads, threads, 1, TimeUnit.MINUTES, <END> new LinkedBlockingQueue<Runnable>()); this.responses = new LinkedBlockingQueue<Future<DocumentRevsList>>(threads) { @Override public boolean add(Future<DocumentRevsList> documentRevsListFuture) { boolean offerResult; try { offerResult = offer(documentRevsListFuture, 5, TimeUnit.MINUTES); } catch (InterruptedException ie) { throw new RuntimeException("Offer interrupted", ie); } if (!offerResult) { throw new RuntimeException("Offer timed out"); } return true; } }; this.completionService = new ExecutorCompletionService<DocumentRevsList>(executorService, responses); this.requestsOutstanding = new AtomicInteger(requests.size()); for (final BulkGetRequest request : requests) { completionService.submit(new Callable<DocumentRevsList>() { @Override public DocumentRevsList call() throws Exception { return new DocumentRevsList(GetRevisionTaskThreaded.this.sourceDb.getRevisions (request.id, request.revs, request.atts_since, GetRevisionTaskThreaded.this .pullAttachmentsInline)); } }); } }</code><technical_language>this ThreadPoolExecutor identical core max thead number configuration I this is essentially a fixed size thread pool alive time effect (because reduce core threads anyway). I Executors.newFixedThreadPool(threads) more concise</technical_language>

Target:
public GetRevisionTaskThreaded(CouchDB sourceDb, List<BulkGetRequest> requests, boolean pullAttachmentsInline) { Preconditions.checkNotNull(sourceDb, "sourceDb cannot be null"); Preconditions.checkNotNull(requests, "requests cannot be null"); for(BulkGetRequest request : requests) { Preconditions.checkNotNull(request.id, "id cannot be null"); Preconditions.checkNotNull(request.revs, "revs cannot be null"); } this.sourceDb = sourceDb; this.requests = requests; this.pullAttachmentsInline = pullAttachmentsInline; this.executorService = Executors.newFixedThreadPool(threads); this.responses = new LinkedBlockingQueue<Future<DocumentRevsList>>(threads) { @Override public boolean add(Future<DocumentRevsList> documentRevsListFuture) { boolean offerResult; try { offerResult = offer(documentRevsListFuture, responseTimeout, responseTimeoutUnits); } catch (InterruptedException ie) { throw new RuntimeException("Offer interrupted", ie); } if (!offerResult) { throw new RuntimeException("Offer timed out"); } return true; } }; this.completionService = new ExecutorCompletionService<DocumentRevsList>(executorService, responses); this.requestsOutstanding = new AtomicInteger(requests.size()); for (final BulkGetRequest request : requests) { completionService.submit(new Callable<DocumentRevsList>() { @Override public DocumentRevsList call() throws Exception { return new DocumentRevsList(GetRevisionTaskThreaded.this.sourceDb.getRevisions (request.id, request.revs, request.atts_since, GetRevisionTaskThreaded.this.pullAttachmentsInline)); } }); } }