tags:

views:

67

answers:

2

Hello Team,

I am working on an Android Application where I need to work on thread which is a well known concept of Java. I am having a thread named "thrd" in my application and I want to call it in the else part of the IF...Else loop.

Can anyone please tell me how can I call that thread in my loop, Sorry I am totally new as far as working with Java or Android is concerned.

Thanks for the help in Advance, david

A: 

Threads are just Java object, so you need a thread reference on the thread you want to start. I think it's impossible (or not a good idea if possible) to get such a reference form a thread name. Here is code sample to get started with threads:

// This class extends Thread class 
BasicThread1 extends Thread { 
     // This method is called when the thread runs 
      public void run() { 
        // Your code here
      } 
} 

// Create and start the thread 
Thread thread = new BasicThread1(); 
thread.start(); 
Manuel Selva
A: 

Look at the AsyncTask. May be it better match to you.

Sergey Glotov