• Post Reply Bookmark Topic Watch Topic
  • New Topic

start & run methods  RSS feed

 
Betsy Camel
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry if this question is being repeated . But i need to know the need of start method when we can directly call the run method ?
whats the main difference between the two.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24215
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thread.start() is the "magic" method that actually creates a separate thread of execution. You call start(), and start()'s implementation does the magic necessary to make run() execute asynchronously.

You can call run() yourself, but it's absolutely pointless: run() is just a plain ordinary method, and if you call it, the caller will wait for it to return, just like any other method.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!