java学习(157):线程的引入
生活随笔
收集整理的這篇文章主要介紹了
java学习(157):线程的引入
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
//線程
public class test102 extends Thread{public void run(){while (true){System.out.println("我是線程1"+this.getName());try {Thread.sleep( 1000 );}catch (InterruptedException e){e.printStackTrace();}}}
}
//線程
public class test103 extends Thread{public void run(){while (true){System.out.println("我是線程2"+this.getName());try {Thread.sleep( 1000 );}catch (InterruptedException e){e.printStackTrace();}}}
}
測(cè)試類
public class test104 {public static void main(String[] args){test102 one=new test102();test103 two=new test103();one.start();two.start();System.out.println( "我是主方法" );} }運(yùn)行結(jié)果
總結(jié)
以上是生活随笔為你收集整理的java学习(157):线程的引入的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: click vue 重复调用_VUE防止
- 下一篇: 高中计算机编程软件vb,高中年级VB程序