File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
Getting MEAN with Mongo, Express, Angular, and Node
this week in the
start() in java
Sanath Ramesh kumar
Joined: Mar 13, 2012
Mar 14, 2012 08:25:02
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??
Joined: Sep 21, 2011
Mar 14, 2012 08:27:42
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.
Joined: Jan 03, 2004
Mar 14, 2012 10:30:10
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.
Joined: Oct 14, 2005
Mar 14, 2012 11:40:41
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
General threading problem
Open tomcat server in the same dos window.
Regarding the IllegalThreadStateException
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015