File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes start() in java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "start() in java" Watch "start() in java" New topic
Author

start() in java

Sanath Ramesh kumar
Greenhorn

Joined: Mar 13, 2012
Posts: 4
Why does the start() automatically call the run()??What happens if the developer explicitly calls run() and also please explain the difference between above two scenarios??
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
Calling run directly will execute that method in the current thread. Only by calling start will a new thread be created for the run method to execute in.
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

Sanath Ramesh kumar wrote:Why does the start() automatically call the run()??


Because the code for start() calls the native method start0(), which has code that says, "Start a new thread of execution, and in it, call this object's run() method."

In other words, it's because that's how the code is written, just like any other time one method calls another.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

To those beginners who don't know what this post was about: It was about the start() and run() methods of the Thread class.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: start() in java