views:

47

answers:

2

Does a batch file execute processes in sequence only if the previous step has completed and released all file/process locks?

Suppose I have the following cmd file (mybatchfile.cmd)

echo. |TIME
java myjar.jar
echo. |TIME

and I pipe the results to a log file.

Can I be 100% confident (on windows) that my java process has completed and released all file/process locks when the second echo timestamp has occurred?

A: 

Yes, provided java wasn't killed, you can be confident it has completed normally. Regardless, the locks will be released.

Matthew Flaschen
Maybe I'm wrong, but I think this would apply even if it was killed?
spong
+1  A: 

If your Java program launches another process then no, you have no control. For the most part it is a reasonable assumption, not 100%

EDIT: Another item that might take a while are server sockets. The sockets might be in a WAIT state for a while before being released by the OS.

Romain Hippeau