Martin,
I was thinking we could special case the first thread and have it do the
initialization when "safe". (The first thread is the only case where it
appears to be its own parent, or in other words, where
Thread.currentThread()==this.
But let's not hijack this thread for this discussion.
Cheers,
David
Martin Buchholz said the following on 03/13/09 10:37:
On Thu, Mar 12, 2009 at 17:21, Andrew John Hughes
<gnu_and...@member.fsf.org> wrote:
I agree. I also noticed that Thread uses a synchronised block to do
the increment rather than the atomic. I don't know if there'd be any
advantage to changing it or whether there is a good reason it was done
like that.
java.lang.Thread should utilize Atomics for global counters
Category
http://bugs.sun.com/view_bug.do?bug_id=6741261
I tried to replace the use of static synchronized with Atomics in Thread.java,
but there was a circular static initialization dependency, so I gave up.
David Holmes, you might want to close 6741261as Will Not Fix.
Or Andrew, you might want to prove me wrong and implement it properly.
It's probably not worth it - thread creation is going to be slow no matter what,
so the global lock is unlikely to be contended.
Martin