R
Robert Nurse
Hi All,
I'm curious about something. In a Java certification study guide,
they have the following code and they ask what the result is:
class MyThread extends Thread
{
public static void main(String [] args)
{
MyThread t = new MyThread();
Thread x = new Thread(t);
x.start();
}
public void run()
{
for (int i = 0; i < 3; ++i)
{
System.out.print(i + "..");
}
}
}
It's simple enough. Except, earlier in the text (and in the Java API)
they mention that the only constructors for the Thread class are:
Thread()
Thread(Runnable target)
Thread(Runnable target, String name)
Thread(String name)
Thread(ThreadGroup group, Runnable target)
Thread(ThreadGroup group, Runnable target, String name)
Thread(ThreadGroup group, Runnable target, String name, long
stackSize)
Thread(ThreadGroup group, String name)
I don't see Thread(Thread). And I don't see how it can be a Runnable
except for that they share the same method: run().
I'm curious about something. In a Java certification study guide,
they have the following code and they ask what the result is:
class MyThread extends Thread
{
public static void main(String [] args)
{
MyThread t = new MyThread();
Thread x = new Thread(t);
x.start();
}
public void run()
{
for (int i = 0; i < 3; ++i)
{
System.out.print(i + "..");
}
}
}
It's simple enough. Except, earlier in the text (and in the Java API)
they mention that the only constructors for the Thread class are:
Thread()
Thread(Runnable target)
Thread(Runnable target, String name)
Thread(String name)
Thread(ThreadGroup group, Runnable target)
Thread(ThreadGroup group, Runnable target, String name)
Thread(ThreadGroup group, Runnable target, String name, long
stackSize)
Thread(ThreadGroup group, String name)
I don't see Thread(Thread). And I don't see how it can be a Runnable
except for that they share the same method: run().