Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

object.run() is the thread running?

 
Vinod Vinu
Ranch Hand
Posts: 217
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi... i have a very basic question about threading. I know that to use threading in our class we need to either implement Runnable interface or extend the Thread class to our class and then call start() to bring the thread into its life cycle. A thread can be brought into its life cycle only after calling is one and only one method i.e. start().




My question is if i call run() directly then what it is doing exactly ? What i think is that it is just calling the run() and working as a normal class method only. And it has not behaving like a thread i.e. not bringing the thread into its life cycle.
 
Matthew Brown
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's right. It'll just execute the run() method in the current thread, and no new threads will be created.
 
Vinod Vinu
Ranch Hand
Posts: 217
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks buddy ...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic