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 ArticleAnswer 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 ArticleAnswer by Ajay for "implements Runnable" vs "extends Thread" in Java
Lambda expression with functional programming in java
View ArticleAnswer 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