Results 1 to 5 of 5
  1. #1
    nagesh1811 is offline Member
    Join Date
    Jul 2008
    Posts
    7
    Rep Power
    0

    Default My Simple Thread program not giving proper out put ...plz help me

    package com.nag.javaThread;


    public class ThreadTest {

    public static void main(String args[]){

    System.out.println("I am executed___1");
    /*DispThread dt1= new DispThread("Hello");*/
    DispThread dt1= new DispThread();
    System.out.println("I am executed___2");
    dt1.start();
    System.out.println("I am executed___3");

    }
    }

    class DispThread extends Thread{

    /*String message;
    public DispThread (String msg){

    this.message=msg;
    }*/
    public void Run()
    {
    System.out.println("I am exeucting from DispThread class:___1 ");
    /* for (int i=0;i<10;i++){
    //System.out.println(message);
    }*/
    }
    }
    Last edited by nagesh1811; 02-27-2012 at 06:01 PM.

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,015
    Rep Power
    10

    Default Re: My Simple Thread program not giving proper out put ...plz help me

    What output did you expect? What output are you getting?

    Please use the code tags when posting code.

    Hint- Java is case sensitive.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    nagesh1811 is offline Member
    Join Date
    Jul 2008
    Posts
    7
    Rep Power
    0

    Default Re: My Simple Thread program not giving proper out put ...plz help me

    [QUOTE=nagesh1811;268418]package com.nag.javaThread;


    public class ThreadTest {

    public static void main(String args[]){

    System.out.println("I am executed___1");
    /*DispThread dt1= new DispThread("Hello");*/
    DispThread dt1= new DispThread();
    System.out.println("I am executed___2");
    dt1.start();
    System.out.println("I am executed___3");

    }
    }

    class DispThread extends Thread{

    /*String message;
    public DispThread (String msg){

    this.message=msg;
    }*/
    public void Run()
    {
    System.out.println("I am exeucting from DispThread class:___1 ");
    for (int i=0;i<10;i++){
    //System.out.println(message);
    }
    }
    }

    My Run Method is not invoking after calling dt1.start();

  4. #4
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,015
    Rep Power
    10

    Default Re: My Simple Thread program not giving proper out put ...plz help me

    Like I said, please use code tags when posting code. And also like I said, Java is case sensitive. Main != main, String != string, etc.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  5. #5
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,173
    Rep Power
    20

    Default Re: My Simple Thread program not giving proper out put ...plz help me

    Use [code] tags [/code] so that we can actually read the code.

    Also, if that is your actual code (capitalisation and all) then take Kevin's hint regarding Java being case-sensitive...

    Finally, you shouldn't extend Thread, but should implement Runnable. Extending Thread is generally considered bad practice.
    That would also highlight the error you have made.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Real simple code giving me trouble!
    By dre in forum New To Java
    Replies: 1
    Last Post: 09-24-2011, 06:13 PM
  2. Simple program, simple problem
    By taymilll in forum New To Java
    Replies: 12
    Last Post: 06-20-2011, 06:12 AM
  3. Replies: 1
    Last Post: 07-23-2010, 03:42 PM
  4. New help with simple Thread Question
    By shuks in forum New To Java
    Replies: 6
    Last Post: 01-11-2010, 03:31 AM
  5. Giving Change: A Rudimentary Program (Questions)
    By carlodelmundo in forum New To Java
    Replies: 8
    Last Post: 08-14-2008, 12:33 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •