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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T07:10:01+00:00 2026-05-31T07:10:01+00:00

output of this program comes as Inside Thread Inside Thread , How this is

  • 0

output of this program comes as “Inside Thread Inside Thread” , How this is happening?

class MyThread extends Thread 
{ 
    MyThread() {} 
    MyThread(Runnable r) {super(r); } 
    public void run() 
    { 
        System.out.print("Inside Thread ");
    } 
} 
class MyRunnable implements Runnable 
{ 
    public void run() 
    { 
        System.out.print(" Inside Runnable"); 
    } 
} 
class ThreadRunnableBoth 
{  
    public static void main(String[] args) 
    { 
        new MyThread().start();
        new MyThread(new MyRunnable()).start(); 
    } 
}

I can understand how first “Inside Thread” is printing but for second time print I am expecting to print “Inside Runnable” but it prints “Inside Thread” , how this is happening ?
Please explain …..thanks a lot

  • 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-31T07:10:02+00:00Added an answer on May 31, 2026 at 7:10 am

    The run() method of java.lang.Thread simply calls target.run(), where target is the Runnable provided during construction. However, in MyThread, you’ve overridden this functionality; your version of run() ignores the target and prints “Inside Thread” instead.

    One way to fix it is to run your Runnable with an instance of the base Thread class:

    new Thread(new MyRunnable()).start();
    

    Other possibilities would be not to override run(), or to call super.run() from your override.

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

Sidebar

Related Questions

Can anyone explain the output of this program and how I can fix it?
can any one give me the dry output for this program? #include <stdio.h> main()
When I attempt to compile the output of this trivial lex program: # lex.l
I have this output when trying to debug Program received signal SIGSEGV, Segmentation fault
I have written the following C program. The output is 32. Why is this?
When i run the above program in gcc complier(www.codepad.org) i get the output as
Finally i am able to run super user commands in android program. Now i
Input: $string = this-is-just-an--example Output: this is just an-example Tried various things centered around
I have a variable which I get from database I want to output this
The output of this echo is not passed on to the next command using

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.