Java: "implements Runnable" vs. "extends Thread"

Posted by user65374 on Stack Overflow See other posts from Stack Overflow or by user65374
Published on 2009-02-12T14:28:46Z Indexed on 2012/07/06 15:16 UTC
Read the original article Hit count: 130

Filed under:
|

From what time I've spent with threads in Java, I've found these two ways to write threads.

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


public class ThreadB extends Thread {
    public ThreadB() {
    	super("ThreadB");
    }
    public void run() {
    	//Code
    }
}
//with a "threadB.start()" call

Is there any significant difference in these two blocks of code?

© Stack Overflow or respective owner

Related posts about java

Related posts about multithreading