RFR: JDK-8152690: main thread does not have native thread name
Yasumasa Suenaga
yasuenag at gmail.com
Thu Mar 24 23:48:01 UTC 2016
Hi Robbin,
2016/03/25 1:51 "Robbin Ehn" <robbin.ehn at oracle.com>:
>
> Hi Yasumasa,
>
> I'm not sure why you don't set it:
>
> diff -r ded6ef79c770 src/share/vm/runtime/thread.cpp
> --- a/src/share/vm/runtime/thread.cpp Thu Mar 24 13:09:16 2016 +0000
> +++ b/src/share/vm/runtime/thread.cpp Thu Mar 24 17:40:09 2016 +0100
> @@ -3584,6 +3584,7 @@
> JavaThread* main_thread = new JavaThread();
> main_thread->set_thread_state(_thread_in_vm);
> main_thread->initialize_thread_current();
> + main_thread->set_native_thread_name("main");
> // must do this before set_active_handles
> main_thread->record_stack_base_and_size();
> main_thread->set_active_handles(JNIHandleBlock::allocate_block());
>
> here instead? Am I missing something?
Native thread name is the same to thread name in Thread class.
It is set in c'tor in Thread or setName().
If you create new thread in Java app, native thread name will be set at
startup. However, main thread is already starte in VM.
Thread name for "main" is set in create_initial_thread().
I think that the place of setting thrrad name should be the same.
> The launcher seem to name itself 'java' and naming this thread just
> 'main' is confusing to me.
>
> E.g. so main thread of the process (and thus the process) is 'java' but
> first JavaThread is 'main'.
The native main thread in the process is not JavaThread. It is waiting for
ending of Java main thread with pthread_join().
set_native_thread_name() is for JavaThread. So I think that we do not need
to call it for native main thread.
Thanks,
Yasumasa
> Thanks!
>
> /Robbin
>
> On 03/24/2016 03:26 PM, Yasumasa Suenaga wrote:
> > Hi all,
> >
> > HotSpot for Linux will set thread name via pthread_setname_np().
> > However, main thread does not have it.
> >
> > All JavaThread have native name, and main thread is JavaThread.
> > For consistency, main thread should have native thread name.
> >
> > I uploaded a webrev. Could you review it?
> >
> > http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.00/
> >
> > I cannot access JPRT.
> > So I need a sponsor.
> >
> >
> > Thanks,
> >
> > Yasumasa
> >
More information about the hotspot-runtime-dev
mailing list