Sunday, 15 January 2012
JAVA : Diff between Runnable Interface and Thread class while using threads.
Do you like this Article?
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.
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.
Subscribe to:
Post Comments
(
Atom
)
Popular Posts
-
public - public means everyone can access it.That means it's in global scope. As, main method is called by JVM [ Java Virtual Machine...
-
throw is used to throw an exception in a program, explicitly . Whereas, throws is included in the method's declaration part, wi...
-
Singleton in one of the most popular yet controversial design pattern, in the world of object oriented programming. It's one of t...
-
Web Container / Servlet Container / Servlet Engine : In J2EE Architecture , a web container (also known as servlet container or ser...
-
Program compiles. But at runtime throws an error “NoSuchMethodError”.
-
Vector : It's synchronized. It's slower than ArrayList. It's generally used in ...
-
doGet(): protected void doGet(HttpServletRequest req, HttpServletResponse resp)throws ServletException, java.io.IOException – is a met...
-
In Java Programming Language , we must declare a variable name and type, before using it. The data type of a variable defines the th...
0 Responses to “ JAVA : Diff between Runnable Interface and Thread class while using threads. ”
Post a Comment