[concurrency-interest] Re: Thread.getId()

Larry Riedel larryr@saturn.sdsu.edu
27 Jan 2004 18:19:16 -0000

> Even though all of the Thread API is in our docs, we (JSR166) didn't
> have anything to do with getID(), which was put in as part of
> management, monitoring, and profiling APIs (mainly JSR163 and JSR174).
> I believe the spec is written conservatively to enable conforming
> implmentations when Isolates (JSR121) finally become available. Each
> Isolate will need a part of the ID range, and those ranges will need
> to be reusable.

It seems a shame to me that an API operation so significant
in the context of concurrency, and so fundamentally related
to concurrency, would be considered out of scope for an
active working group chartered specifically with concurrency
related APIs.

For me to be able to trivially and almost instantaneously
determine whether or not the thread executing my code already
executed the same (and/or some other) code before seems like a
capability which could be pretty valuable to me.  Is there a
different way to (nearly) as trivially and efficiently retrieve
from a thread a value I can uniquely and efficiently associate
in the same way with that thread for the lifespan of the [JVM],
regardless of the lifespan of the thread?