• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

Reasoning question on Thread  RSS feed

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I have a very general question about Thread class method.

In any class if we have a method foo() then we call it using foo().

then why do we call run() using start() in the case of Threads?

I guess to show a different process started running?

any concrete answers?

Regards
Shailesh
 
shailesh jamloki
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think I got the answer:-

It is possible to call the run() method as run(). but It really do not start a separate call stack.

to call run() with start() is a mechanism to start it in a different mechanism.

But Is this really a reason?
 
Sheriff
Posts: 21502
96
Chrome Eclipse IDE Java Spring Ubuntu VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

shailesh jamloki wrote:It is possible to call the run() method as run(). but It really do not start a separate call stack.


Correct. When you call run() it executes that method in the same thread you are calling it from. start() creates a new thread (lowercase to not confuse it as an instance of class Thread) and will then call run() inside that new thread.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!