Quantcast
Channel: "implements Runnable" vs "extends Thread" in Java - Stack Overflow
Browsing all 45 articles
Browse latest View live

Answer by Jon Skeet for "implements Runnable" vs "extends Thread" in Java

Yes: implements Runnable is the preferred way to do it, IMO. You're not really specialising the thread's behaviour. You're just giving it something to run. That means composition is the philosophically...

View Article


Answer by Powerlord for "implements Runnable" vs "extends Thread" in Java

I'm not an expert, but I can think of one reason to implement Runnable instead of extend Thread: Java only supports single inheritance, so you can only extend one class. Edit: This originally said...

View Article


"implements Runnable" vs "extends Thread" in Java

From what time I've spent with threads in Java, I've found these two ways to write threads: With implements Runnable: public class MyRunnable implements Runnable { public void run() { //Code } }...

View Article

Image may be NSFW.
Clik here to view.

Answer by Ajay for "implements Runnable" vs "extends Thread" in Java

Lambda expression with functional programming in java

View Article

Answer by Yogesh Sharma for "implements Runnable" vs "extends Thread" in Java

If you want to separate your concerns like, if you want to create Tasks and it does not matter to you who is the worker working on your task then use Runnable and define your work as a task. Just like...

View Article

Browsing all 45 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>