forum

Home / DeveloperSection / Forums / difference between "implements Runnable” and “extends Thread”

difference between "implements Runnable” and “extends Thread”

Anonymous User 2248 08-May-2015
From what time I've spent with threads in Java, I've found these two ways to write threads:

With implements Runnable:

public class ThreadA implements Runnable {
    public void run() {
        //Code
    }
}
//Started with a "new Thread(threadA).start()" call
Or, with extends Thread:

public class ThreadB extends Thread {
    public ThreadB() {
        super("ThreadB");
    }
    public void run() {
        //Code
    }
}
//Started with a "threadB.start()" call
Is there any significant difference in these two blocks of code ?

Updated on 08-May-2015
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By