Is There a Java Process ID For Each Process?



I have a program that logs actions to a file. I've noticed that sometimes,
by accident, two instances of the program (each with a different JVM) ended
up running at the same time. It took a while to sort through the entries
to be sure I knew which entry was from which instance.

Is there some way to get an instance number or process ID for each process
-- one that I can be sure will be different for each program I run, with
different instances of the JVM -- in other words, I don't want the first
process or thread started by a JVM to be #1, and the 2nd to be #2. I'm
looking for some type of unique ID number that would be associated with
each Java program I run.

I'm sure there's some way I can do this by getting the system time,
generating a random number, and concatenating them, but I'm hoping there's
something in the Java API that will easily provide the kind of unique PID I
need.

Thanks for any help.

Hal
.



Relevant Pages

  • Re: Inactivity detect
    ... One way to avoid polling the system time could be using ... All events in the JVM. ... > using your class for the system event queue? ...
    (comp.lang.java.gui)
  • Re: Manipulate objects in heap
    ... > a Java program. ... > Does the Sun JVM or other implementations of JVM allow this via their ... tend to have cutting-edge GC implementations of their own, ... use the IBM "jikes" JVM as a basis (not to be confused with the jikes ...
    (comp.lang.java.programmer)
  • Re: Mutiple JVM in Single Os
    ... Actually we trigger a java program which will execute ... other java program in seperate JVM. ...
    (comp.lang.java.programmer)
  • Re: Java app with strange timezone behavior
    ... tt looks like the sysadmin had never restarted the JVM after the ... system time was changed. ... While it looked like the functionality was ... triggered by cron jobs, there was an underlying server stub ...
    (comp.lang.java.programmer)
  • jvm, timezone and SUSE
    ... If your Java program displays the time one ... defacto standard now. ... then the jvm will behave. ... Since init scripts don't source ...
    (alt.os.linux.suse)