Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

start() and run()

 
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
Marshal
Pie
Posts: 20880
75
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic