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

  • Home
  • SEARCH
  • 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 7631875
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T06:28:11+00:00 2026-05-31T06:28:11+00:00

What is the difference between the two thread calls below? Will the two calls

  • 0

What is the difference between the two thread calls below?
Will the two calls act similarly?

NOTE: I am not using #1 & #2 at the same time, which is the best option.

private void startConnections(){
    ServerThread server = new ServerThread();
    server.start(); // #1
    Thread serverThread = new Thread(server);
    serverThread.start(); //#2
}

class ServerThread extends Thread{
    public void 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-31T06:28:13+00:00Added an answer on May 31, 2026 at 6:28 am

    The first approach is acceptable, but discouraged. The second one works, but is broken/hard to understand. Consider the third one:

    class ServerRunnable implements Runnable {
      public void run(){}
    }
    
    Runnable run = new ServerRunnable();
    Thread serverThread = new Thread(run);
    serverThread.start();  //#3
    

    #1

    This is pretty common approach – in order to create a new thread you are simply subclassing it and calling start() method. Many people, including myself, find this idiom being a poor practice – it unnecessarily couples task (contents of run() method) with threading (Thread class).

    #2

    I have never seen code like this and although technically working, I would correct it immediately. Even though you are creating a thread instance, you are passing it to another thread and starting the latter. So why creating the first thread on the first place? Note that Thread also implements Runnable, so it technically works, but is really awkward.

    #3

    So what do I recommend? Implement Runnable interface that is not coupled to threading. You cannot run Runnable in a separate thread alone, you have to explicitly create that thread. But having raw Runnable also allows you to easily switch from native thread to for instance thread-pool.

    Technically you can extend Thread and put such a “runnable” in a thread pool, but this is really hard to understand and you are also unnecessarily carrying Thread baggage (it is quite a big class).

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

Sidebar

Related Questions

What is the difference between the two pieces of code below? Will there be
Possible Duplicate: How to calculate the difference between two dates using PHP? I have
Possible Duplicate: How to calculate the difference between two dates using PHP? When a
Possible Duplicate: How to calculate the difference between two dates using PHP? how can
Possible Duplicate: How to calculate the difference between two dates using PHP? I have
I am trying to synchronize two thread (working on the same C++ map) using
I'm wondering what is the difference for application between those two calls, in means
How to calculate minute difference between two date-times in PHP?
What is the difference between two ways to obtain a string from resources: setPositiveButton(R.string.some_string);
I want to calculate the difference between two times, one of which is the

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.