I am using java and going to do some rest calls using Zephyr's api. I don't think the the api used will affect the possibility of my question. I was just wondering if it is possible make the same rest call multiple times at the same time using multithreading? Each call would be retrieving different data, they are not all grabbing the same data.
This is just strictly for retrieving data, not writing.
If this is possible, what are the risks? Is this recommended?
For sure, it will improve your performance if you implement it the right way. As mentioned, you just need to be careful with the implementation to avoid security and performance issues. I'd suggest to have a thread pool, so you can manage many threads that are performing the REST calls you're doing at the same time.
ThreadPoolExecutor
will be helpful.
You can use Executors.newFixedThreadPool
/Executors.newCachedThreadPool
. Both of them works fine.
You can create a task (implementing Callable
) to perform your REST invokation or call, and then use the invokeAll(
) of the ThreadPoolExecutor
(You would like to include the list of the tasks here).
Hope it helps you.
Best regards.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With