This is a bit related to this question.
I'm using make to extract some information concerning some C programs. I'm wrapping the compilation using a Bash script that runs my Java program and then gcc. Basically, I'm doing:
make CC=~/my_script.sh
I would like to use several jobs (-j option with make). It's running several processes according to the dependency rules.
If I understood well, I would have as many instances of the JVM as jobs, right?
The thing is that I'm using sqlite-jdb to collect some info. So the problem is how to avoid several processes trying to modify the db at the same time. It seems that the SQLite lock is JVM-dependent (I mean one lock can be "seen" only inside the locking JVM), and that this is the same for RandomAccessFile.lock().
Do you have any idea how to do that? (Creating a temporary file and then looking if it exists or not seems to be one possibility, but may be expensive. A locking table in the DB?)
java.nio.channels.FileLock allows OS-level cross-process file locking.
However, using make to start a bash scripts that runs several JVMs in parallel before calling gcc sounds altogether too Rube-Goldbergian and brittle to me.