• Post Reply Bookmark Topic Watch Topic
  • New Topic

thread

 
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: 3166
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!