GeeCON Prague 2014*
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


JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "multithreading" Watch "multithreading" New topic
Author

multithreading

rupika deval
Greenhorn

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

Joined: Mar 22, 2005
Posts: 42047
    
  64
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
Greenhorn

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
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

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
Greenhorn

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: http://aspose.com/file-tools
 
subject: multithreading