We have one program in Java and one in Python, and you need to collect them in the form of a ping-pong, each time exchanging an entire array of 100,000 in length and taking 0.1-1 second to do your job:
- Java does some work and runs an int array with a length of 100,000 ...
- Python that does some work and launches a new array with a length of 100,000 ...
- Java that does some work ... etc.
note that
- Each program needs to wait until the other makes it part.
- They will run on the same Linux machine.
- We will do Monte Carlo simulations, so speed is important.
I am more familiar with Java and understand that a file approach with shared memory support is likely to be the fastest. This seems to be relevant for the Java side, but how can I make each program wait / block so that the other ends its work and updates the shared memory before it starts reading? I heard about something called a semaphore, but I can’t understand.
These are my backup ideas, but maybe they are better?
source
share