Take the 2-minute tour ×

I am writing a app, which has to create multiple Resources. The input is a XML. I need to parse the XML, create the Resources in parallel and update the responses in the Ouputs.

        <CreateResourceARequest> ...</CreateResourceARequest>

Each of the ResourceRequests are handled by a specific Classes.

What is the best way to create Resources in parallel, aggregate the results and update the xml ?

share|improve this question
I'm sorry, but what do you mean by "in parallel" here? –  Hovercraft Full Of Eels Jul 4 '11 at 16:13
add comment

1 Answer

up vote 1 down vote accepted

you will parse xml file in single thread anyway because the file is linear. but you can collect you parsers for each CreateResourceCRequest in a set and start them all in parallel threads after parsing file

share|improve this answer
sometimes I need to ensure that a resource needs to be created before other resources are created. How do I ensure that ? –  Santhosh S Jul 6 '11 at 11:30
exec = Executors.newCachedThreadPool(); exec.execute(new CreateResourceA(input)); exec.execute(new CreateResourceB(input)); exec.execute(new CreateResourceB(input)); exec.shutdown(); while (!exec.isTerminated()){ logger.debug("some tasks are still running"); } ----- currently I am doing it this way, but this does not ensure ResourceA to be created before ResourceB. –  Santhosh S Jul 6 '11 at 14:27
add comment

Your Answer


