// Set up the concurrent data structures so we can reprocess the
// documents concurrently using a work queue
final BlockingQueue<Runnable> workQueue =
new LinkedBlockingQueue<Runnable>();
for (int i = 0; i < Runtime.getRuntime().availableProcessors(); ++i) {
Thread t = new WorkerThread(workQueue);
t.start();
}
final Semaphore documentsRerocessed = new Semaphore(0);
for (int d = 0; d < numDocuments; ++d) {
final int docId = d;