This is a pretty basic problem.
I'm working on a piece of middleware between two large applications that cannot be altered. My little function is the squishy bit in the middle
Application #1: A huge computational powerhouse that has an exposed jar with one function that I use (simulated here by the function runAlgorithm)
Application #2: A desktop UI that calls my middleware and expects a result in the same
thread.
Here's some sample code
The problem:
So looking at the example code, main() is basically the UI calling my function. I cannot edit main(), I cannot do anything to main. It calls my function and expects a result
Also runAlgorithm() is the massive server behind the scenes. I cannot edit runAlgorithm, I cannot do anything other than expect a result.
Instead of chaining all my runAlgorithm()'s in a row, it is perfectly fine for me to thread them out in my performFunction() call. My question is what would be (given the sparse details above) the best way to proceed? Should I thread out all of my runAlgorithms() and sleep inside performFunction() until they all respond? Is there a better way?
Any help would be appreciated.
Thanks!