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

Brian Goetz brian@quiotix.com
Mon, 26 Jan 2004 17:32:15 -0800

> > > > public long getId()
> > > > I think it should be prohibited for the jvm to reuse a thread id, I
> > > > simply can't see any reason why it should be allowed.
> >
> > This clause seems to exist in order to handle the potential theoretical
> > exhaustion of IDs.
>If the ID was incremented every nanosecond, would it wrap
>around in less than 100 years?  It seems pretty crazy
>to me as well, especially since it would be trivial to
>implement using AtomicLong.getAndAdd(). :-)  Maybe there
>was a predecessor that returned an int?

This seems a sensible theory.  An int could easily wrap around in the 
lifetime of a long-running program (on the order of a month at 1000 
threads/second) but a long would take a loooooong time to wrap -- we will 
probably be using 256-bit processors long before then.

Brian Goetz
Quiotix Corporation
brian@quiotix.com           Tel: 650-843-1300            Fax: 650-324-8032