Results 1 to 9 of 9

Thread: Thread !!

  1. #1
    java4amanda is offline Member
    Join Date
    Jan 2012
    Posts
    55
    Rep Power
    0

    Default Thread !!

    Hi all,

    I wrote a simple thread code like below.


    class Mythread implements Runnable

    {


    public void run()

    {

    dojob();

    }

    public void dojob()

    {

    System.out.println("hi");

    }

    public static void main(String[] args)

    {

    Mythread mt = new Mythread();

    Thread td = new Thread(mt);

    td.start();

    }

    }

    Now when i run the above code i get compile time error stating "cannot find symbol new Thread(mt)", "cannot find symbol td.start()" !!
    Can any one kindly tell me what the problem might be?
    Regards

  2. #2
    Sierra is offline AN21XX
    Join Date
    Mar 2012
    Location
    Munich
    Posts
    297
    Rep Power
    3

    Default Re: Thread !!

    I see no error - works fine when I compile it in Eclipse Indigo

  3. #3
    java4amanda is offline Member
    Join Date
    Jan 2012
    Posts
    55
    Rep Power
    0

    Default Re: Thread !!

    No try running that through simple command prompt.

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,202
    Rep Power
    19

    Default Re: Thread !!

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  5. #5
    Sierra is offline AN21XX
    Join Date
    Mar 2012
    Location
    Munich
    Posts
    297
    Rep Power
    3

    Default Re: Thread !!

    Hmmm prints a "hi" to my screen - how do you compile it?
    Maybe give me the line you use to run it on your system?

  6. #6
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,202
    Rep Power
    19

    Default Re: Thread !!

    Delete any Thread.java /Thread.class files that you have created yourself.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  7. #7
    java4amanda is offline Member
    Join Date
    Jan 2012
    Posts
    55
    Rep Power
    0

    Default Re: Thread !!

    compile >>> javac Mythread.java

    Run >>> java Mythread

  8. #8
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,967
    Rep Power
    19

    Default Re: Thread !!

    You haven't got another class called Thread in that directory have you?
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  9. #9
    java4amanda is offline Member
    Join Date
    Jan 2012
    Posts
    55
    Rep Power
    0

Similar Threads

  1. Main Thread not waiting for grand child thread to finish
    By prashanthn in forum Threads and Synchronization
    Replies: 3
    Last Post: 06-07-2011, 09:26 AM
  2. Difference between Thread.yield() and Thread.sleep() methods
    By Nageswara Rao Mothukuri in forum New To Java
    Replies: 12
    Last Post: 07-30-2010, 05:37 PM
  3. how to reduce the thread sleep time and wake up the thread
    By baktha.thalapathy in forum Threads and Synchronization
    Replies: 2
    Last Post: 06-24-2010, 07:36 PM
  4. Replies: 0
    Last Post: 01-28-2008, 07:02 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
  •