update:demo10

This commit is contained in:
dichgrem
2026-01-13 21:24:59 +08:00
parent 6922192da4
commit 6ce5c76843
3 changed files with 77 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
package com.study.demo10;
public class MultiTaskThread {
public static void main(String[] args) {
Runnable task1 = () -> {
for (int i = 0; i < 3; i++) {
System.out.println("任务一 - " + Thread.currentThread().getName());
}
};
Runnable task2 = () -> {
System.out.println("任务二 - " + Thread.currentThread().getName() + " - 正在处理业务...");
};
Thread thread1 = new Thread(task1, "线程A");
Thread thread2 = new Thread(task2, "线程B");
thread1.start();
thread2.start();
}
}