public class NumberRunnable implements Runnable
{ private int k;
public NumberRunnable(int k)
{
this.k=k;
}
public NumberRunnable()
{
this(0);
}
public void run()
{
int i=k;
System.out.println();
while(i<50)
{
System.out.print(i+" ");
i+=2;
}
System.out.print("结束!");
}
public static void main(String args[])
{
NumberRunnable odd=new NumberRunnable(1); //创建具有线程体的目标对象
Thread thread_odd=new Thread(odd,"奇数线程"); //以目标对象创建线程对象
thread_odd.start();
new Thread(new NumberRunnable(2),"偶数线程").start();
}
}
请问什么是目表对象?以目标对象创建的线程对象是怎么执行run方法的? |