-1

How run method is identified by start() method in threading? What is the internal mechanism in start() method which directly calls run() method. Thanks in advance.

Umesh Pithiya
  • 34
  • 1
  • 6
  • is this your question ? http://stackoverflow.com/questions/8579657/java-whats-the-difference-between-thread-start-and-runnable-run – Shayan Pourvatan Mar 12 '16 at 10:37
  • no.i'm not asking difference.but i want to know why start calls run method. – Umesh Pithiya Mar 12 '16 at 10:50
  • @Umesh start() does not call the run() method directly, (or indirectly), so there can be no 'why'. Call/return is a stack-based transfer of control and, since every thread has its own private stack, it is not possible to call one thread from another, by definition. – Martin James Mar 12 '16 at 22:46

1 Answers1

1

In simple terms, If you don't create a new thread (without calling start()), run() will be executed on the current thread. start() method creates a new thread and then run() is called on that thread. When you call Thread.start(), it starts a new thread and calls the run() method of object internally to execute it within that new thread which indeed is the purpose of Multithreading.

FallAndLearn
  • 3,855
  • 1
  • 15
  • 24
  • Thanks.I tried both method in progress bar. I found the difference my app was hanged while i used run() and when i used start() i got my answer. – Umesh Pithiya Mar 14 '16 at 10:40