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

Nathan Reynolds nathan.reynolds at oracle.com
Wed Jun 26 12:54:52 EDT 2013


 > public static final long getThreadId(Thread thread) {

Doesn't it make more sense to have a member method instead of a static 
method?

Nathan Reynolds 
<http://psr.us.oracle.com/wiki/index.php/User:Nathan_Reynolds> | 
Architect | 602.333.9091
Oracle PSR Engineering <http://psr.us.oracle.com/> | Server Technology
On 6/26/2013 3:43 AM, Doug Lea wrote:
> On 06/25/13 19:03, Doug Lea wrote:
>>
>
>> We can and probably should fix this immediately by grabbing
>> the Thread's "tid" field instead of calling getId.
>
> I committed this change to jsr166 sources, so it should eventually
> make its way into OpenJDK.
>
>
>> On the form of the added method:
>> By analogy to Object.hashCode() (orverridable) vs
>> System.identityHashCode(Object) (not). maybe the
>> best place for this method is System.getThreadId(Thread)?
>
> Or less disruptively, it might as well be in class Thread, but
> with spec wording adapted from System.identityHashCode:
>
>     /**
>      * Returns the identifier for the given Thread, as would
>      * be returned by the default {@link #getId} method,
>      * whether or not the thread's class overrides {@code getId()}.
>      *
>      * @param thread the thread
>      * @return the id
>      */
>     public static final long getThreadId(Thread thread) {
>         return thread.tid;
>     }
>
>
>
> _______________________________________________
> Concurrency-interest mailing list
> Concurrency-interest at cs.oswego.edu
> http://cs.oswego.edu/mailman/listinfo/concurrency-interest
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20130626/0d6f5cdf/attachment.html>


More information about the Concurrency-interest mailing list