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

Thread concepts

Gopinath Ranga
Greenhorn

Joined: May 09, 2008
Posts: 25
hi all,
what is the diffenerce between Runnable interface and Thread class?
where do we use them?


thanks and regards<br /> <br />Gopi R.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

"GopiNath R",
Welcome to JavaRanch!

We're pleased to have you here with us here on the ranch, but there are a few rules that need to be followed, and one is that proper names are required. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious. Initials are OK for the first and middle names but not the last. You can change it here


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4659
    
    5

Originally posted by GopiNath R:
hi all,
what is the diffenerce between Runnable interface and Thread class?


Do you understand the difference between an interface and a class?
Phal Ach
Ranch Hand

Joined: May 09, 2008
Posts: 54
See you have to be specific about what you want to ask. Obvious answer to your question looks like Runnable is interface and Thread is class. If you mean to ask how are they different in terms of working, then following is your answer:

If you extend Thread then your class also becomes a thread and you cannot extend anything else. But if you implement Runnable interface, you have option to extend another Class maybe Animal or Car or whatever and also get the thread benefits by implementing Runnable.

In both the cased you just have to override run(). Call thread.Start and it will go to run method directly.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Thread concepts