| Author |
start() and run()
|
Ankur kothari
Ranch Hand
Joined: Sep 06, 2009
Posts: 531
|
|
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
Joined: Sep 28, 2004
Posts: 16815
|
|
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
|
Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
|
 |
 |
|
|
subject: start() and run()
|
|
|