-
Expert Member
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]
-
Junior Member
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
-
Forum Rules