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
OCA Java SE 8 Programmer I Study Guide 1Z0-808
this week in the
Threads and Synchronization
Thread interview question
sanjay kumar gupta
Joined: May 15, 2008
Feb 15, 2012 07:20:45
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.
Joined: Aug 05, 2005
Feb 15, 2012 07:52:17
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.
Author and ninkuma
Joined: Jan 10, 2002
Feb 15, 2012 08:16:41
Please take the time to choose an appropriate forum for your posts. This forum is for questions on
, not threading. For more information, please click this link ⇒
This post has been moved to a more appropriate forum.
Asking smart questions
Books by Bear
I agree. Here's the link:
subject: Thread interview question
Theard Class and Runnable interface
class calling thread without extending Thread class
Relationship between Thread class and Runnable interface?
Why Thread class is present
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015