1. Learn
  2. /
  3. Courses
  4. /
  5. Optimizing Code in Java

Connected

Exercise

Implementing a thread pool for batch processing

Imagine you're developing a document processing system that needs to handle multiple documents simultaneously. Each document requires intensive processing that should be done in parallel, but you want to limit the number of concurrent operations to prevent system overload. You'll implement a solution using ExecutorService to efficiently manage the processing workload.

Instructions

100 XP
  • Create a fixed thread pool, containing 3 threads.
  • Submit the processDocument(doc) method as a task to the executor.
  • Shutdown the executor without forcing termination immediately.