java线程的使用方法
java的调用线程的方法一:
class Demo extends Thread
{
Demo(){}
Demo(String name)
{
super(name);
}
public void run()
{
System.out.println("所要执行的内容");
}
}
class ThreadDemo
{
public static void main(String[] args)
{
Demo t = new Demo()
t.start();
}
}
java调用线程的方法二(实现Runnable接口)
class Demo implements Runnable
{
public void run()
{
System.out.println("实现想要的功能");
}
}
class ThreadDemo
{
public static void main(String[] args)
{
Demo d = new Demo();
Thread t = new Thread(d);
t.start();
}
}
待完续