This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Hi friend's, I want to synchronize the execution of java program main method. I means if I running the Hello. java from one console and I want don't want to run that program from another console. Is this possible in java? Regards from Parshuram Walunjkar
The problem with that is that they are running from separate processes in their own JVMs. I would guess that you could create some persistant flag in a database or file and have the main method check that flag as it's first step. If it is not set - then set it (making sure that you write it back out to the file) and continue running. When complete you would need to unset the flag. If it is already set just exit gracefully.
"JavaRanch, where the deer and the Certified play" - David O'Meara
You could have the program open a socket (or start an RMI server) when it starts. New processes can check for previosly running servers and perhaps even send some commands (i.e. if it's a file editor, there could be a way to open a file in a pre-existing process).