當前位置:編程學習大全網 - 網站源碼 - QT中,多線程的RUN()函數,如是數組開啟的多個線程,run()函數的功能怎麽實現不壹樣的功能?

QT中,多線程的RUN()函數,如是數組開啟的多個線程,run()函數的功能怎麽實現不壹樣的功能?

線程就是為了更好地利用CPU,

提高程序運行速率的!

public class TestThread1{

public static void main(String[] args){

Runner1 r=new Runner1();

//r.run();//這是方法調用,而不是開啟壹個線程

Thread t=new Thread(r);//調用了Thread(Runnable target)方法。且父類對象變量指向子類對象。

t.start();

for(int i=0;i<100;i++){

System.out.println("進入Main Thread運行狀態");

System.out.println(i);

}

}

}

class Runner1 implements Runnable{ //實現了這個接口,jdk就知道這個類是壹個線程

public void run(){

for(int i=0;i<100;i++){

System.out.println("進入Runner1運行狀態");

System.out.println(i);

}

}

}

  • 上一篇:如何用js設置a標簽做到像百度搜索後最下面的分頁效果
  • 下一篇:我用中文編寫的公式,怎麽上傳到股票軟件上?代碼怎麽用
  • copyright 2024編程學習大全網