Click here to Skip to main content


QuestionCreating a Thread PinmemberCsTreval2-Oct-12 9:17 
Consider the following code:
public class MyThread extends Thread {
    public void run(){
        System.out.println("Testing thread.");
public class App 
    public static void main( String[] args )
        MyThread thread = new Thread();
Why does the syntax checker not accept line 5 in '' (The one with the MyThread Reference Type)? If MyThread is aThread, then why is it incorrect to create a new Thread out of it? I know I'm supposed to replace it with new MyThread, but why is Thread not allowed? Doesn't 'extend' mean 'inherits all properties etc.'?
AnswerRe: Creating a Thread Pinmemberjschell2-Oct-12 9:46 
AnswerRe: Creating a Thread PinmvpRichard MacCutchan2-Oct-12 10:32 
GeneralRe: Creating a Thread PinmemberCsTreval2-Oct-12 21:53 
GeneralRe: Creating a Thread PinmemberTorstenH.3-Oct-12 0:31 
AnswerRe: Creating a Thread PinmemberPeter_in_27802-Oct-12 23:05 
AnswerRe: Creating a Thread PinmemberGowtham Gutha15-Nov-12 8:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Advertise | Privacy | Mobile
Web02 | 2.8.141223.1 | Last Updated 26 Dec 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid