John Cowan a écrit :
> On Thu, Apr 3, 2008 at 1:43 PM, John Rose <[EMAIL PROTECTED]> wrote:
>
>
>> Even better (if applicable) would be to have fast thread-local counters,
>> with a slow background phase which occasionally tallies them into a trailing
>> global counter.
>>
>
> That reminds me of an old question of mine. In the case where a
> thread has been created from an object whose class is a subclass of
> Thread, is Thread.currentThread() guaranteed to give you back the same
> object? IOW, if I say:
>
> class MyThread extends Thread { ... }
> myThread = new MyThread();
> myThread.start();
> ...
>
> then in the new thread, is Thread.currentThread() always == to the
> original value of myThread?
yes
> If so, that provides a different approach
> to thread-local state, where the state is held in the instance
> variables of MyThread objects,
yes, ThreadLocal is currently implemented has a field of
java.lang.Thread storing a map,
so there is no synchronization.
> and the JVM is used to thread them
> through :-) the code until the point where they're needed.
>
>
cheers,
Rémi
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "JVM
Languages" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/jvm-languages?hl=en
-~----------~----~----~----~------~----~------~--~---