Thread.setName question

David Holmes David.Holmes at oracle.com
Tue Aug 10 22:00:40 UTC 2010


Hi Xiaobin,

Xiaobin Lu said the following on 08/11/10 07:42:
> Would anyone please let me know why we convert the incoming argument of 
> Thread.setName() to a char array? Why can't we just store the incoming 
> argument to the name since String is immutable anyways?

I know I've wondered the same thing in the past, and I can't recall the 
exact details of what I determined at the time. The only thing I 
presently recall is that the name is accessed directly from VM code 
(internally and things like JVMTI) - hence a raw char array is easier to 
access than a String object.

David





More information about the core-libs-dev mailing list