Pausing a java program and then having a different program start it up
I was wondering if there was a way to tell my Java program to stop and wait until the operating system or another program tells is to continue, and then the question is how would a different program (let's say it's a different Java) program would make it move? Is that possible?
The issue in more detail is this: I have a java program-A that runs and outputs a file1, another program-B then uses file1 runs and outputs file2 and I want the first program-A to take that file2 and do some work on it and so forth... but I have no way for program-A to know if program-B is done. Thus I want program-A to go to sleep until program-B writes the file and nudges program-A. Program-B doesn't have to be a Java program, it might be C, perl, or even matlab.
If this isn't possible is there a way that is?
[818 byte] By [
mikebasa] at [2007-11-27 10:17:57]

It is absolutely possible. The most professional way to do it would be to do it all with web services based on XML schemas (.xsd files)
Program A does something, makes a web call to Program B, then Program B calls back program A when it's done
> what I'm really interested for is a version of what
> is done in C:
> pause()--Suspend Process Until Signal Received
You can do this by listening on some update event - either a file system update or incoming data on a socket or so.
1. If the other process is willing to use them too, you could try file locks.
2. Program B could write to a temp file, then rename it to the proper name
when done writing. Program A could then just poll for the appearance of the file.
> how would it poll for the appearance of the file?
> just keep checking if it exists?
Yes, I mean sleeping then checking, and doing that in a loop. Nothing fancy, but it works.
> Also a note this is all being done on Windows. So is
> there some windows command that can be executed that
> will stop the process and wait for osmething to
> resume it?
You can manage that in your code the way BDLH's mentioned. The program waiting on the new file would sleep/pause or run an infinite loop until it finds the file with the name it is expecting. It will essentially be paused and will resume when it finds the file name.