Results 1 to 2 of 2

Thread: Syntax for Runnable extends Thread

  1. #1
    Expert Member
    Join Date
    Oct 2006
    Answers
    209

    Syntax for Runnable extends Thread

    Class kk implements Runnable extends Thread This syntax is correct or not. Is it give any ambiguities in a program when we compile this? Which method override this?

    NOTE : [This question was asked by Srivani]


  2. #2
    Junior Member
    Join Date
    Dec 2006
    Answers
    5

    Re: Syntax for Runnable extends Thread

    hi jobhelper
    there is not any ambiguity in this syntax and this compiles fine
    here is the code.........
    which displays "hi" ten times on the screen......
    public class kk extends Thread implements Runnable
    {
    Thread th;
    String name;
    public kk()
    {
    name = "hi";
    th = new Thread(this);
    th.start();
    }
    public void run()
    {
    for(int i=0;i<10;i++)
    {
    try
    {
    sleep(1000);
    }
    catch(InterruptedException exr)
    {
    System.out.println(exr.getMessage());
    }
    System.out.println(name);
    }
    }

    public static void main(String []ar)
    {
    new kk();
    }
    }


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact