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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:47:45+00:00 2026-05-24T19:47:45+00:00

I am using some threads in java android, I have a class which implements

  • 0

I am using some threads in java android, I have a class which implements the runnable interface, for this i need to have a run method and this run method is called when a thread starts for example thread.start(), my problem is that i dont know how to run 2 different run methods and 2 threads. skeleton of code is below. please help on this or some explanation.Thanks a lot.

public class myTutorialsDetailsRequest implements Runnable {

    //on click of button 1 start the below thread 
        Thread thread = new Thread(this);
    thread.start();

      public void run() {
       //do get data 1
      }
    //onlick of button 2 start the below thread 
         Thread thread2 = new Thread(this);
    thread2.start();

      public void run() {
       //do get data 2
      }
}
  • 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-24T19:47:46+00:00Added an answer on May 24, 2026 at 7:47 pm

    Implement your own subclass of Thread for each thread you need. You may either define one class in one file or the common way (but maybe a bit harder to read for Java beginners) is to do so inline by using an anonymous class:

    Thread thread1 = new Thread(){
        public void run() {
            //...
        }
    }.start();
    

    This defines a new subclass of Thread without giving it a name.
    Do the same for the second thread.

    However, consider carefully whether you really need to spawn a new thread for whatever it is you have to do.

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

Sidebar

Related Questions

This is a Java syntax question, but just for some background. Using android, I
Today I had to fix some older VB.NET 1.0 code which is using threads.
I think this is a general Java question, but it does involve some Android
Hy! I'm adapting a chat using sockets and threads from java client to android
I have a thread that downloads some images from internet using different proxies. Sometimes
Using some of the methods, I am able to check the orientations to which
I am using some custom controls one of which is a tooltip controller that
I am using some code which was originally taken from the Apple sample ViewTransitions
I'm using MacOsX 10.6.4. Some time ago I run into problems with Eclipse (it
I have often heard that using break s in Java is considered bad practice,

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.