You need to migrate a bunch of documents from an external resource. You're given a list of document identifiers documentIds, which can be used to access and process the external documents. Processing a single document takes time (it needs to be downloaded and processed), and all of these actions are done using the SingleDocumentProcessor interface (so we don't need to worry about how the documents are processed).
Your task is to process the given document ids and return the corresponding list of processed documents.
Try to take into account the following factors:
make your solution applicable for multithreaded environments;
think of an approach which is applicable for a distributed environment, where your code is executed in a cluster of several machines;
make your solution as efficient as possible.
[execution time limit] 50 seconds