This week's book giveaway is in the OCAJP forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line!
See this thread for details.
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

Win a copy of OCA Java SE 8 Programmer I Study Guide 1Z0-808 this week in the OCAJP forum!
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: 2409
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: 19110

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