aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes start() and run() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "start() and run()" Watch "start() and run()" New topic
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: 18896
    
  40

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)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: start() and run()