标签:
Java多线程编程
(1) 继承Thread类实现多线程
代码示例:
package com.example.thread; public class MyThread { /** * @param args */ public static void main(String[] args) { ThreadDemo t1 = new ThreadDemo("A"); ThreadDemo t2 = new ThreadDemo("B"); t1.start(); t2.start(); } } class ThreadDemo extends Thread { private String name; public ThreadDemo(String name) { this.name = name; } public void run() { super.run(); for (int i = 0; i < 10000; i++) { System.out.println(name + ":" + i); } } }
标签:
原文地址:http://www.cnblogs.com/rzhy007/p/4632555.html