pedja
pedja

Reputation: 3413

Background thread Android

I have a question about threading in android

If call a method which is in my activity from a run() method of a new thread is that method executed in that new thread or in main thread. for example.

  ...
  public void run()
   {
    someMethod(); //some method declared in activity  
    }
  ...

Upvotes: 1

Views: 244

Answers (3)

Rohit Jain
Rohit Jain

Reputation: 213243

Since each Thread has its own stack, and given that Threads don't share stack. So, once a thread is started, then any method invoked from it will be executed in that Thread only.

Upvotes: 3

Arvind Kanjariya
Arvind Kanjariya

Reputation: 2097

When thread is create it has it's own stack. So whatever methods you call from that thread is execute in that thread's stack only.

Upvotes: 0

JB Nizet
JB Nizet

Reputation: 691735

Yes. Every method you call is executed in the current thread.

Upvotes: 2

Related Questions