Reputation:
I have two java applications. They are very simple: they insert 500,000 rows of fake data into a MongoDB database and SQL database respectively. I time each operation.
How can I launch these two java files at the exact same time?
Upvotes: 0
Views: 562
Reputation: 43391
How exact does exact mean? Running them at exactly the same time is going to be damn near impossible, and fully impossible on a single-core machine (not that those still exist...).
But the easiest thing, if you want them launched very quickly, is:
java -jar first.jar & java -jar second.jar
If there's some startup time that you want to synchronize after, you could rig them both such that they busy-wait for a signal from an external event (such as a file appearing). Then start them both up, wait for them to warm up, and trigger the signal.
Upvotes: 3
Reputation: 597234
There is no need to start them at the same time (and you can't be 100% exact). You just have to measure how much time each one executes.
If this doesn't suit you, perhaps you can setup 2 crons to start the two applications.
Upvotes: 2