[concurrency-interest] RRWL with 'bad' Thread.getId() implementations

Aleksey Shipilev aleksey.shipilev at oracle.com
Tue Jun 25 15:24:04 EDT 2013


On 06/25/2013 09:24 PM, Nathan Reynolds wrote:
> The JavaDoc for Thread.getId() says "...thread ID is unique..." so I
> don't think this is a bug in RRWL.  

+1. Intentionally breaking the Thread contract does seem bad.

> I find it very interesting that threadInitNumber and threadSeqNumber are
> both used in the Thread class.  It seems we only need 1.  It seems that
> the constructor should use "Thread-" + tid for a thread name.  In fact,
> the name could read "Thread-10" and the tid could be 7 because there is
> a race between when the name is generated and the tid is set.  The
> mismatch probably doesn't matter functionally.  However, it could make
> it easier for debugging.

In addition, we could finally eliminate those synchronized{} in JDK 8.
(Since Thread is the primordial class, you can't easily use atomics
there, but now as we have Unsafe.getAndAdd*... ;)

This looks like a good and simple task for a newcomer to OpenJDK. If
anyone from the community is interested in prototyping the patch,
testing it, and pushing through OpenJDK, but does not know where to
start, PM me ;)

-Aleksey.


More information about the Concurrency-interest mailing list