Friday, 6 September 2013

Two instances of same class running via main - what is their associated unique identifier of each thread of main?

Two instances of same class running via main - what is their associated
unique identifier of each thread of main?

I am running the main method of a class twice, simultaneously via
different executions and was looking at what would uniquely identify each
one as it was running. It was simple to create something in myself:
String sid = UUID.randomUUID().toString();
...but is there anything inherent in each running execution - part of the
executing class - that I could use as a unique identifier.
We did a few approaches ourselves to see that we didn't know of something
available we could use. We first wondered about using
Thread.currentThread().getName() but both are main. I can't use toString()
because there is no instance.


Edit:
This class (GettingRollingClient) is what I'm running twice
simultaneously, trying to differentiate between the two as they run...
re-using a Java feature if I can:

java -cp "hazelcast-client-3.0.1.jar:hazelcast-3.0.1.jar:."
GettingRollingClient

No comments:

Post a Comment