aspose file tools*
The moose likes Threads and Synchronization and the fly likes Thread interview question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "Thread interview question" Watch "Thread interview question" New topic
Author

Thread interview question

sanjay kumar gupta
Greenhorn

Joined: May 15, 2008
Posts: 17
I have one doubt about Thread (I have face this question in an interview and searching for answer):-

to get Thread instance we have options
1. extend Thread class
2.after implementing Runnable interface

question is why do we need Thread class even we can get same things after implementing runnable interface directly ?

I have given answer in interview,

that Thread class implement runnable interface so we no need to implement methods again but interviewer was not satisfied with this answer.

and other answer which we always give for this question :

we can extend any other class when we use runnable interface.

please give your view.
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3156
    
  10
The Thread class creates the new thread and then runs your Runnable class in it. If you didn't have the Thread class all your classes that implement Runnable would also have to include code to create and manage a thread.


Joanne
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60041
    
  65

Please take the time to choose an appropriate forum for your posts. This forum is for questions on JSP, not threading. For more information, please click this link ⇒ CarefullyChooseOneForum.

This post has been moved to a more appropriate forum.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Thread interview question
 
Similar Threads
Why Thread class is present
Thread concepts
Relationship between Thread class and Runnable interface?
Theard Class and Runnable interface
class calling thread without extending Thread class