Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8347323
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T07:19:46+00:00 2026-06-09T07:19:46+00:00

How to set the same name for parent and child in this situation? public

  • 0

How to set the same name for parent and child in this situation?

public class ComponentA {
    public static void main(String[] args){

        Bye bye = new Bye();
        Thread t = new Thread(bye);
        t.start();
    }
}

I cannot add t.setName(Thread.currentThread().getName());, because I need to avoid changing code. I’m looking for solution I can apply from AspectJ class.
Is there any way to put an argument to run method? Or maybe in child thread we can get parent name?

EDIT:

I mean:

  • parent – main in ComponentA
  • child – run in Bye
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T07:19:48+00:00Added an answer on June 9, 2026 at 7:19 am

    Edit:

    Is there any way to put an argument to run method? Or maybe in child thread we can get parent name?

    Once the thread has started and the run() method has been called, there is no way to find out the name of the parent thread as was discussed in this answer here:

    How to find the name of the parent thread?

    You can certainly do:

    Bye bye = new Bye();
    Thread t = new Thread(bye, Thread.currentThread().getName() + "-child");
    t.start();
    

    This sets the name of the newly created thread to be related to the current thread which is it’s parent. But with the edit you made, I see that you can’t change how the thread has been forked.

    As was mentioned in my other answer, I think you are going to have to use some other mechanism aside from the name to group your threads.

    Inside of the run() method, you can certainly make a call to add the current thread into some collection of threads for reporting purposes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say I've got two tables: Parent id | name Child id | parentId |
I have the following (simplified) Hibernate entities: @Entity @Table(name = package) public class Package
I have a simple 1:many aggregate relationship, lets say: public class Parent { public
I have the following viewmodel: public class ViewModel { [Display(Name = firstname, ResourceType =
I am trying to model a parent/child association where a Parent class (Person) owns
Can the application use set same char in the XON and XOFF? If yes,
i want to set imagesize same with the content size of the scrollview after
Setup: Multiple sites on Django on the same set of servers, being served by
Shown are two scatter charts on the same set of data, which contains some
Two trees are said to be identical if they contain same set of elements

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.