电动二通阀:一个java小程序,有几行搞不懂,谁能帮忙看看啊

来源:百度文库 编辑:神马品牌网 时间:2024/04/19 14:08:03
class DaemonThread
{
public static void main(String [] args)
{
ThreadTest t = new ThreadTest();
Thread tt = new Thread(t);
tt.setDaemon(true);
tt.start();
}
}

class ThreadTest implements Runnable
{
public void run()
{
while(true)
{
System.out.println(Thread.currentThread().getName() + " is running.");
}
}
}

第五,六行看不懂~~~~~谁能帮忙解释下啊
为什么实例tt的时候,后面括号里为什么要有t

实现线程,有两种方法,一种是继承Thread类,一种是实现Runnable接口。

这里是使用第二种方法实例化了tt这样一个Thread对象。

看一下有关线程方面的资料

一楼说的对呀