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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T12:24:44+00:00 2026-05-15T12:24:44+00:00

Please explain the output of the below code: If I call th1.run() , the

  • 0

Please explain the output of the below code:

If I call th1.run(), the output is:

EXTENDS RUN>>
RUNNABLE RUN>>

If I call th1.start(), the output is:

RUNNABLE RUN>>
EXTENDS RUN>>

Why this inconsistency? Please explain.

class ThreadExample extends Thread{
    public void run() {
        System.out.println("EXTENDS RUN>>");
    }
}

class ThreadExampleRunnable implements Runnable {
    public void run() {
        System.out.println("RUNNABLE RUN>>");
    }
}

class ThreadExampleMain{
    public static void main(String[] args) {
        ThreadExample th1 = new ThreadExample();
        //th1.start(); 
        th1.run();

        ThreadExampleRunnable th2 = new ThreadExampleRunnable();
        th2.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-15T12:24:44+00:00Added an answer on May 15, 2026 at 12:24 pm

    The Thread.start() method starts a new thread, the entry point for this thread is the run() method. If you call run() directly it will execute in the same thread. Given that calling Thread.start() will start a new thread of execution, the run() method may be called after (as in you example) the rest of the main method executes.

    Change your main method to call th1.start() and run repeatedly, you will see that sometimes it outputs:

    EXTENDS RUN>>
    RUNNABLE RUN >>
    

    and sometimes it outputs:

    RUNNABLE RUN >>
    EXTENDS RUN>>
    

    depending on how java chooses to schedule your 2 threads.

    Check out the java tutorial on this.

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

Sidebar

Related Questions

Please explain me below situation What would be the output? interface A{} class B
I tried this and got the output as: void Please explain the following Code:
Can someone please explain why this program outputs 0x00000004? class AndAssignment { static void
Please explain what this task is about? Create a generic linked list class that
Could someone please explain why this happening: class Apple { String type; setType(){ System.out.println(inside
Can someone please explain this to me? I have the following code: <form action=<?php
Program followed by output. Someone please explain to me why 10,000,000 milliseconds from Jan
Can anyone explain to me why GetInterfaces() in the below code returns an interface
Can someone please explain to me what goes to the Output window in VS?
Could you please explain why the shell redirection doesn't work with System.Diagnostics.Process class? I

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.