class thread1 extends Thread
{ file://自定義線程的run()方法;
public void run()
{
System.out. }
} 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()方法啟動線程;
}
} 新聞熱點
疑難解答