Share on Google+Share on Google+

SrikanthAmneer
Diff between Runnable Interface and Thread class while using threads
1 Answer(s)      6 years and 3 months ago
Posted in : Java Beginners

Diff between Runnable Interface and Thread class while using threads

Ads

View Answers

January 10, 2011 at 3:35 PM


Hi Friend,

Difference:

1)If you want to extend the Thread class then it will make your class unable to extend other classes as java is having single inheritance feature whereas If you implement runnable interface, you can gain better object-oriented design and consistency and also avoid the single inheritance problems.

2)Extending the thread will give you simple code structure in comparison to Runnable Interface.

3)Using Runnable Interface, you can run class several times whereas Thread have the start() method that can be called only once.

Thanks










Related Tutorials/Questions & Answers:
Diff between Runnable Interface and Thread class while using threads
Diff between Runnable Interface and Thread class while using threads  Diff between Runnable Interface and Thread class while using threads  ... to Runnable Interface. 3)Using Runnable Interface, you can run class several
Diff between Runnable Interface and Thread class while using threads
Diff between Runnable Interface and Thread class while using threads  Diff between Runnable Interface and Thread class while using threads  ... to Runnable Interface. 3)Using Runnable Interface, you can run class several
Advertisements
Difference between extends thread class vs implements runnable interface - Java Interview Questions
Difference between extends thread class vs implements runnable interface  Hi Friends, can you give difference between extending thread class... Runnable Interface, you can run the class several times whereas Thread have
Threads on runnable interface - Java Beginners
Threads on runnable interface  need a program.....please reply asap Create 2 threads using runnable interface.First threads shd print "hello....  Hi class MyThread extends Thread{ MyThread(String s
Threads on runnable interface - Java Beginners
Threads on runnable interface  need a program.....please reply asap Create 2 threads using runnable interface.First threads shd print "hello....  Hi manshi, i am sending simple code of thread. class MyThread
Runnable interface in java
In this section we will learn about Runnable interface in java. In java thread are created by two ways, one by extending Thread class and another one by implementing Runnable interface
Creation of Multiple Threads
than one thread (multithreads) in a program using class Thread or implementing... create the same program implenting the Runnable interface: class MyThread1... Thread or interface Runnable to implement thread in your program. Download
Java : Runnable Thread
by using Runnable interface. class RunnableThread implements Runnable... a thread by implementing the Runnable interface. You need to implement a single.... After creating class that implements Runnable interface, you can create object
Java Thread and Runnable
Java Thread and Runnable  What's the difference between Thread and Runnable types
Java Runnable Interface
is an interface. Thread class implements it. Java has multithreading facility. Thread is also created by implementing the Runnable interface. Java Runnable Thread Example public class runnable1 implements Runnable { @Override
Diff between ArrayList and Vector?
Diff between ArrayList and Vector?  What's The Difference between ArrayList and Vector Classes and Can you give me a simple Program for set and List Interface
Difference between abstract class and an interface
Difference between abstract class and an interface The difference between abstract class and interface is one of the most popular question in the interview... between abstract class and interface in java. Abstract class is a class
What are the difference between abstract class and interface?
What are the difference between abstract class and interface?  What are the difference between abstract class and interface
diff between encapsulation and abstraction code
diff between encapsulation and abstraction code  diff between encapsulation and abstraction code
diff between spring and struts in java
diff between spring and struts in java  diff between spring and struts in java
implements runnable n extends thread - Java Beginners
implements runnable n extends thread  what is the difference between implements runnable n extends thread? public class...(); class StringThreadImplement implements Runnable { private String } }  Hi public class
Diff between Struts1 and struts 2? - Struts
interfaces. While in Struts 2, an Action class implements an Action interface, along...Diff between Struts1 and struts 2?  What are the difference... safe or synchronized while developing an application. Struts 2 doesn?t have thread
Creation of MultiThreads
class Thread or interface Runnable to implement thread in your program... create more than one thread (multithreads) in a program using class Thread..., lets create the same program implenting the Runnable interface: class
Count Active Thread in JAVA
of active threads in the current thread group. Example : class ThreadCount...Count Active Thread in JAVA In this tutorial, we are using activeCount() method of thread to count the current active threads. Thread activeCount
Java Thread class
It is created by extending the Thread class or implementing Runnable interface Java Thread Class Example public class thread1 extends Thread { @Override... Java Thread Class is a piece of the program execution Java has
diff between encapsulation and abstraction code with output
diff between encapsulation and abstraction code with output   diff between encapsulation and abstraction code with output
diff between encapsulation and abstraction code with output
diff between encapsulation and abstraction code with output   diff between encapsulation and abstraction code with output
diff between encapsulation and abstraction code with output
diff between encapsulation and abstraction code with output   diff between encapsulation and abstraction code with output
Creation of MultiThreads
thread (multithreads) in a program using class Thread or implementing interface.... It means, you can use either class Thread or interface Runnable to implement thread... by extending Thread Class:  class MyThread extends 
Threads
Threads  Extends Thread or Implementing Runnable Interface... flexibility for the Runnable implementation to extend another class. 2)Separates the code from execution 3)Allows you to run your runnable from a Thread Pool
Interface Vs Abstract Class
Interface Vs Abstract Class       There are three main differences between an interface and an abstract..., an interface is equivalent to a fully abstract class (a class with only public abstract
Threads - Java Interview Questions
to Runnable Interface. 3)Using Runnable Interface, you can run the class several...Threads  creating a thread is two ways?extends with thread class and implements runnabule interface. What is the diffrence between those two?which
Difference between Timer and Thread?
Difference between Timer and Thread?  Can anyone tell me about the difference between Timer and Thread, Why we need to have Timer in case we have Thread implimentation startegy in Java
Creating multiple Threads
they are as follows: By implementing Runnable interface. By extending Thread class. While implementing Runnable interface or extending Thread class, you have... class B extends Thread { public void run() { System.out.println(); for (int i
thread class - Java Beginners
and notifies the other thread about this value - The decrementor threads... the following code: class Incrementor extends Thread{ int cnt1 = 0; boolean...; } } class Decrementor extends Thread{ int cnt2 = 100; int cnt1
Diff Bn Marker Interface and instanceOf - Java Interview Questions
Diff Bn Marker Interface and instanceOf   Hi Friends, Wats d difference bn Marker Interface and instanceOf method. Thanks
Tutorials   
Java Spring Hibernate Struts Training What does core Java include? java What are some way to learn Java quickly? Is it required to learn Java before learning Java Script? Is it necessary to learn java script before learning PHP? Are HTML5 and Java Script boosts Java career? Is Java object oriented? Fingerprint application with Java Uninstall Oracle Virtual Box JSON to HashMap Free Java online Training I want example of Control Statement in Java ANSI Color Codes with Python Create a Program that Calculates Input What is difference between JDK,JRE and JVM? How to see ubuntu version on server? How to get Page Source in Selenium (WebDriver) using Java? The path to the driver executable must be set by the webdriver.gecko.driver system property parse data from a link in java Java Program Qns using BlueJ How to fix HAX Kernel Module Is Not Installed error? Installing Audacity Looking for code Logic to check track changes & Coments in MSWord, MSWordx, MSExcel, MSExcelx is ON/OFF Installing JDK on Mac SAX Parser exception ERROR 601 (42P00): Syntax error. Encountered Thread java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactory How to install Ubuntu 16.04 LTS? HttpServletRequest cannot be resolved to a type in eclipse - Solved Unhandled event loop exception GC overhead limit exceeded Spring Data jpa with apache phoenix Caused by: java.lang.IllegalArgumentException: Not a host:port pair: PBUF o.a.h.h.z.RecoverableZooKeeper - Possibly transient ZooKeeper, quorum= com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager class not found com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager not found How to download and install Java 8 on Windows? How to uninstall JDK 7? How to install gtk-doc-tools package in Ubuntu? How to install Oracle JDK 8 on Ubuntu? ejabberd_ctl.beam not found - Solved How to convert date to UTC format in Java? How to install autoconf, automake and libtool in Ubuntu 15.10? How to convert current date to mm dd yyyy format in Java? How to convert current date to dd mm yyyy format in Java? How to stop window closing in "internalFrameClosing" event. How to find list of all index in Neo4j? neo4j-server.properties file location SASLError using PLAIN: not-authorized how to convert war file into .exe file using java code

Ads

 
Advertisement null

Ads