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

The Archive Base Latest Questions

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

I am trying to build a network related program in Java. I have previous

  • 0

I am trying to build a network related program in Java. I have previous experience with C. In C, when you run thread, you define which method you want it to be run as a thread.

However, in Java, it seems that thread always runs with method run() and there can be 1 method with that name in each class.

I want to have at least 2 threads, one thread for working on calculations, and one thread to work on communications with other applications. (Even if this can be done with 1 thread, I just want to know what would be a correct way to run 2 threads that does totally different jobs)

Below is just a sample code how I implemented the thread. If thread generated by below codes does communication, what would be a nice way to create another thread that does calculation?

public class Server implements Runnable{

    static Thread myThread;


    public void run() {
        // TODO Auto-generated method stub  
    }

    public static void main(String[] args) {
        myThread = new Thread(new Server());
    }


}
  • 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-24T03:21:15+00:00Added an answer on May 24, 2026 at 3:21 am

    Don’t put a main method in the class that implements Thread or Runnable. You could implement what you want with your current Server implementation, but I don’t see a good reason to do so. Separate out the concerns, and KISS:

    • One boring, simple class with a public static void main(String[] args) method
    • One Server implements Runnable class (one type of thread)
    • One Calculations implements Runnable class (the other type of thread)

    The class with the main method would start the Server and Calculations threads.

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

Sidebar

Related Questions

I'm trying build a method which returns the shortest path from one node to
I'm trying to build an MSBuild script that maps a network drive to a
Trying to build a GUI application in Java/Swing. I'm mainly used to painting GUIs
If you're trying to build an application that needs to have the highest possible
I have a SharePoint server running on my network and I am trying to
I am trying to build a Grouped Sectioned View. I want to set an
I want to build web service with Visual studio and run it for testing
i am trying to build a network simulation with OMNet++. Problem is i dont
Trying to build sslsniff on a RHEL 5.2 system here. When compiling sslsniff on
I trying to build and compile my xcodeproj in command line and it is

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.