class thread1 extends Thread
{ file://自定义线程的run()方法;
public void run()
{
System.out.PRintln("Thread1 is running…");
}
}
class thread2 implements Runnable
{ file://自定义线程的run()方法;
public void run()
{
System.out.println("Thread2 is running…");
}
}
class Multi_Thread file://声明主类;
{
plubic static void mail(String args[]) file://声明主方法;
{
thread1 threadone=new thread1(); file://用Thread类的子类创建线程;
Thread threadtwo=new Thread(new thread2()); file://用Runnable接口类的对象创建线程;
threadone.start(); threadtwo.start(); file://strat()方法启动线程;
}
}
新闻热点
疑难解答