File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes R & H Doubts 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 "R & H Doubts" Watch "R & H Doubts" New topic

R & H Doubts

Shachi Singh

Joined: Apr 05, 2007
Posts: 13
can anyone explain me the difference b/w Runnable's run() and Threads Run()
Sanjeev Singh
Ranch Hand

Joined: Nov 01, 2006
Posts: 381
Wecome to Javaranch..
To search the answer of the question lets start with the Runnable interface.It contains only one method names

Thread class itself implements Runnable interface and hence implements the run method.

~Sanjeev Singh<br />SCJP 1.5
marc weber

Joined: Aug 31, 2004
Posts: 11343

Welcome to JavaRanch!

The API documentation is an ideal resource to answer questions like this.

First, note that Runnable is an interface. Looking at Runnable's run method (which is its only method), we see that...
When an object implementing interface Runnable is used to create a thread, starting the thread causes the object's run method to be called in that separately executing thread.

Next, note that Thread is a class that implements Runnable. Looking at Thread's run method, we see that...
If this thread was constructed using a separate Runnable run object, then that Runnable object's run method is called; otherwise, this method does nothing and returns.

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
Shachi Singh

Joined: Apr 05, 2007
Posts: 13
Thanks a lot Marc!
Shachi Singh

Joined: Apr 05, 2007
Posts: 13
Thanks Sanjeev
wood burning stoves
subject: R & H Doubts
It's not a secret anymore!