Hi David, Thanks for your reply. For a lot of enterprise applications (such as the one I work for), a fair amount of time goes to that Thread.setName call which I believe a significant portion is to do new char allocation and copy char array etc. So I think we should give a second thought about how we can efficiently store that field.
-Xiaobin On Tue, Aug 10, 2010 at 3:00 PM, David Holmes <[email protected]>wrote: > 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 > > >
