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 7071373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:40:48+00:00 2026-05-28T05:40:48+00:00

The output is : RunnableA ThreadB I don’t understand how it comes?? (what happens

  • 0

The output is : RunnableA ThreadB
I don’t understand how it comes?? (what happens in the run method in class B)

class A implements Runnable{
    public void run(){
        System.out.println("RunnableA");
    }
}
class B extends Thread{
    B(Runnable r){
        super(r);
    }
    public void run(){
        super.run();
        System.out.println("ThreadB");
    }
}
class Demo{
    public static void main (String []args){
        A a=new A();
        Thread t=new B(a);
        t.run();
    }
}
  • 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-05-28T05:40:48+00:00Added an answer on May 28, 2026 at 5:40 am

    See carefully the implementation of the run method of Thread class its as under :

      public void run() {
        if (target != null) {
            target.run();
        }
        }
    

    So calling the run method of Thread calls the run of the Runnable that is passed , In your case you have passed the instance of A while creating Thread t . So call to super.run() calls the run method of Thread class which in turns calls the run method of the A(which is runnable or the target).

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

Sidebar

Related Questions

public class Threads2 implements Runnable { public void run() { System.out.println(run.); throw new RuntimeException(Problem);
multithreading public class RaceData { public static void main(String[] args) { class UnsafeSequence implements
public class test { public static final int nThreads = 2; public static void
class ZiggyTest{ public static void main(String[] args){ RunnableThread rt = new RunnableThread(); Thread t1
I have a java code like this: private class Uploader implements Runnable { //
I have following program in same file. I have synchronized the run() method. class
Please explain the output of the below code: If I call th1.run() , the
I have a Runnable that reads Console output from an externally called exe (see
How can I prevent from concurrent access. I have code like this public class
I'm trying to use Java's ThreadPoolExecutor class to run a large number of heavy

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.