Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

thread  RSS feed

 
Mukesh Prajapati
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi friends ,
i m new in this site.my question is why we can not call the run() method directly without using start() method ?
please explain it......... thanks
 
Matthew Brown
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mukesh. Welcome to The Ranch!

You can call run() directly if you want. But that will run it in the current thread, and if that was what you wanted you probably wouldn't have bothered creating a Thread object in the first place.

But Thread.start() is different. That will create a new thread, and execute the run() method in that.
 
Mohamed Sanaulla
Bartender
Posts: 3169
34
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mukesh, Welcome to JavaRanch This query has been asked before as well. One of the popular threads for the same.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!