Is There a Java Process ID For Each Process?
- From: Hal Vaughan <hal@xxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 21 Apr 2005 13:40:09 -0400
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
.
- Prev by Date: Re: Removing a null from within a string
- Next by Date: Re: Calling a method
- Previous by thread: Out of Memory Error - WebSphere Application server 4.x
- Next by thread: Validate phone number struts
- Index(es):
Relevant Pages
|