Reputation: 4823
I want to create one method and call the created Thread inside that method in my Android Application, I am new to Java as I had told before.
Can anybody giive me an example of how should I create a method and call a Thread inside that method!
Thanks, david
Upvotes: 0
Views: 1141
Reputation: 5555
I'm not sure I understand your question. You want to start a thread inside a method?
The simplest way is:
public void myMethod() {
new Thread().start();
}
How you might want to do something in this thread, which can be done this way:
public void myMethod() {
new Thread(new Runnable(){
public void run(){
// do something here...
}
}).start();
}
Of course these anonymous objects can be expanded into full-fledged ones.
Upvotes: 2
Reputation: 16116
I'm not sure if it's a duplicate of this question, as I've not done any work on Android. But my answer on there will explain how to run a method inside a thread.
Upvotes: 0