Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

start() and run()  RSS feed

 
Ankur kothari
Ranch Hand
Posts: 531
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


this prints me start.....am i not starting a thread here?

but when i remove the start() the output is run.........why?
 
Henry Wong
author
Sheriff
Posts: 23283
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ankur kothari wrote:
this prints me start.....am i not starting a thread here?


Starting a new thread is done by the start() method. In your example, you overridden the start() method to do something else -- so you are no longer starting a new thread.

Ankur kothari wrote:
but when i remove the start() the output is run.........why?


When you no longer override the start() method -- it will start a new thread which will call your run() method.

Henry
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!