标签:ble executors start 没有 解释 art int 方法 如何
Thread thread1 = new Thread(new Runnable() {
public void run() {
for (int i = 0; i < 1000; i++) {
System.out.println(Thread.currentThread().getName() + "...." + i);
}
}
});
Thread thread2 = new Thread(new Runnable() {
public void run() {
for (int i = 0; i < 1000; i++) {
System.out.println(Thread.currentThread().getName() + "...." + i);
}
}
});
thread1.start();
thread2.start();
运行结果:可见多线程运行是没有顺序的
Thread-1....0
Thread-1....1
Thread-1....2
Thread-2....0
Thread-1....3
Thread-1....4
Thread-1....5
Thread-1....6
thread1.start();
thread1.join();
thread2.start();
thread2.join();
ExecutorService executor = Executors.newSingleThreadExecutor();
executor.submit(thread1);
executor.submit(thread2);
executor.submit(thread3);
executor.shutdown();
标签:ble executors start 没有 解释 art int 方法 如何
原文地址:https://www.cnblogs.com/yejiang/p/12142792.html