Java线程学习03/【线程创建的俩种方法】/byme
2018-02-09 18:30
260 查看
Code:
public class thread03 extends Thread {
private String threadName;
public thread03(String name) {
this.threadName = name;
}
public void run() {
while(true) {
System.out.println("This is " + this.threadName + " thread.");
}
}
}
package lp_2018_02_09_01; public class thread04 implements Runnable { private String threadName; public thread04(String name) { this.threadName = name; } public void paly() { while(true) { System.out.println(this.threadName); } } @Override public void run() { this.paly(); } }
package lp_2018_02_09_01; public class test { public static void main(String [] args) { thread03 lp_1 = new thread03("lp_1"); thread03 lp_2 = new thread03("lp_2"); lp_1.start(); lp_2.start(); thread04 lp_a = new thread04("lp_a"); thread04 lp_b = new thread04("lp_b"); lp_a.run(); lp_b.run(); } }
Effect:
太长,没有截图。相关文章推荐
- Java学习之旅--线程的创建方法
- JAVA学习笔记49——线程概念+进程、线程区别+创建进程三种方法
- java线程学习——创建线程的两种方法
- Java多线程学习之线程的创建方法
- java学习之创建线程方法二
- java学习日记(5)——创建线程的两种基本方法
- java基础学习总结——线程之使用Runnable接口创建线程的方法
- JAVA中创建线程对象的两种方法
- Java创建线程的两个方法
- java学习——线程启动的两种方法,Time定时器,synchronized 的使用
- Java创建线程的两个方法
- Java 线程的创建方法
- Java创建线程的两种方法
- java创建线程的两个方法
- 学习effective java-1创建和销毁对象之静态工厂方法
- 学习effective java-4创建和销毁对象之利用私用构造方法强化类的非实例化
- Java创建线程的两个方法
- [Java] Thread 创建线程的第二种方法
- java中创建线程的两种方法及其区别
- java多线程学习1-继承Thread类和实现Runnable接口来创建线程