This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Threads and Synchronization and the fly likes multithreading Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "multithreading" Watch "multithreading" New topic


rupika deval

Joined: Jan 04, 2008
Posts: 6
why thread class is provided when we can create a thread using runnable interface.
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 41599
Welcome to JavaRanch.

There are times when you need the greater flexibility that extending Thread gives you over implementing Runnable. See ExtendingThreadVsImplementingRunnable for more information.

Since the question has nothing to do with applets -which is what this forum is about- I'll move it to the Threads and Synchronization forum.

Ping & DNS - my free Android networking tools app
P. Jain

Joined: Jan 03, 2008
Posts: 15
By implementing runnable you will only get run method of that interface.

Thread class has many more methods that you can use for handling a multi threaded environment.

SCJP 5.0<br />SCWCD 5.0<br />Preparing for SCDJWS
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24183

Note that you can't "create a thread using runnable interface"; the magic code that actually schedules the OS-level thread to run your code in parallel is in the native methods of the Thread class.

[Jess in Action][AskingGoodQuestions]
Abhijit Choudhury

Joined: Dec 24, 2007
Posts: 11
I dont know about other replies but implementing Runnable interface gives you a choice to extend any other class if you want.

You can have
class ABC extends PQR implements Runnable{

You cant inherit PQR if you extend Thread Class can you?

(Multiple Inheritance NOT ALLOWED Remember)
I agree. Here's the link:
subject: multithreading