写一个简单的java多线程demo

bluesky1年前 ⋅ 996 阅读
public class MultiThreadDemo {
    public static void main(String[] args) {
        Thread threadA = new Thread(new MyThread());
        Thread threadB = new Thread(new MyThread());
        threadA.start();
        threadB.start();
    }
}
class MyThread implements Runnable {
    @override
    public void run() {
        for (int i = 0; i < 5; i++){
            System.out.println("线程:" + Thread.currentThread().getName()  + "->" + i);
        }
    }
}

全部评论: 0

    相关推荐