File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

start() in java

Sanath Ramesh kumar

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

Joined: Sep 21, 2011
Posts: 2413
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

Joined: Jan 03, 2004
Posts: 6109

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

Joined: Oct 14, 2005
Posts: 19973

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:
subject: start() in java
It's not a secret anymore!