位置:首頁 > 軟件操作教程 > 編程開發(fā) > Java > 問題詳情

Java如何寫多線程

提問人:榮凡88發(fā)布時間:2020-10-13

1.分別定義不同的線程類,在各自的run方法中定義線程的工作

 class mythread1 extends Thread

  { public void run{….}    }

  class mythread2 extends Thread

  { public void run{….}    }

2. 在主類中實例化各線程類,并啟動線程.

   public class demo extends Applet

   { public void init()

     { mythread t1=new mythread1();

        mythread t2=new mythread2();

        t1.start(); t2.start();}    }

繼續(xù)查找其他問題的答案?

相關(guān)視頻回答
回復(fù)(0)
返回頂部