This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
Yes, each time you launch a separate JVM... you get a separate JVM. Synchronization doesn't work accross processes.
If you want to run the program 4 times, but not all at once, why not just run it four times from a single script, one after the other? For that matter, why not just put a loop in main(), and run it once? Am I missing something here?
1. synchronized method is a bad idea. 2. synchronization main method is a worse idea.
Are the serperate java calls run in different virtual machines and the reason for it not working is that synchronization doesn't work accross JVMs??
If you can't modify the script there are some tricks you can try. In your main method try to connect to an external java program through RMI. If you cant connect to it, create it. Then you can use that external program to grant each new program the permission to run. You can have it shut itself down when it feels it should.
author and iconoclast
Or you can write a separate Java class which calls the main() in the other class with the options one at a time. The problem we're having is that we don't fully understand your requirements, so we're just guessing solutions.