Every native operating system has some form of thread identifier which can be acquired by calling e.g. pthread_self(). The thread data structure stored in the thread’s local area has more information (e.g. the limits of the current tlab) and the associated Java thread object. For efficiency in 64 bit platforms this thread local area is set to r15 so the Thread.currentThread simply becomes something like returning r15+0x60.
I gave a presentation at JavaOne 2016 which talked a little about this: http://alblue.bandlem.com/2016/09/javaone-hotspot.html Alex > On 26 Mar 2019, at 07:58, joel.wang <290940...@qq.com> wrote: > > Thread.currentThread() is a static and native method. I'm curious about how > it can get the current thread instance. Let's assume linux is its running > platform. > -- > You received this message because you are subscribed to the Google Groups > "mechanical-sympathy" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to mechanical-sympathy+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "mechanical-sympathy" group. To unsubscribe from this group and stop receiving emails from it, send an email to mechanical-sympathy+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.